0

I have a nice integration setup for salesforce using the simple-salesforce Python package. I can easily insert, extract and describe objects across Salesforce.

I would like something similar in order to interact with the data in Marketing Cloud. What is the best solution to be able to query data in data views or data extensions in Marketing Cloud.

Do I need to setup a Marketing Cloud API integration? If so what is the best practice for setting this up and are there any examples of connecting to it? Is this best through the Fuel SDK library?

When trying to authenticate with the example from this site I got a 401 response. I have an installed package called Marketing Cloud API and I added a component that is of type Web App, with read and write to data extensions. I used the client id and secret key associated with the api integration. The json error was {'message': 'Unauthorized', 'errorcode': 1, 'documentation': ''}.

Any thoughts on the error or best practice for this kind of integration would be great, thanks.

def auth(clientId: str,
         clientSecret: str
         ) -> requests.Response:
    end_point = "https://auth.exacttargetapis.com/v1" + "/requestToken"
    headers = {'Content-type': 'application/json'}
    payload = {
        "clientId": clientId,
        "clientSecret": clientSecret,
        "accessType": "offline"
    }
    req = requests.post(
        end_point,
        headers=headers,
        data=json.dumps(payload)
    )
    return req
auth(clientId, clientSecret) 
  • 1
    Pretty standard unauthorized error. This needs more information. How did you get your token? What does your payload look like like? What headers did you add to your request? As far as best practice, the FuelSDK is useful but is not necessarily billed as best practice, or even the official library, by Marketing Cloud, as far as I am aware. They do offer some documentation on using it for various Api calls which is helpful. – Mike May 28 '19 at 17:26
  • Have amended the question to add how I am trying to get a token. – James Wellington May 29 '19 at 10:04
  • This could be caused by the new v2 OAuth token process and likely the SDK runs still using the V1 process. I believe they have removed the capability of building any new apps utilizing V1, so you would need to use either an old v1 app or figure out a new process to gather the token using v2 process to utilize in the SDK. There may be some notes in the GIT for it, I would investigate there. – Gortonington May 29 '19 at 12:56
  • The Fuel SDK have been recently updated to support the new oAuth 2.0 routes. I would suggest downloading the most recent version from the github – EazyE Jun 2 '19 at 1:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.