[SalesForce] How to send authenticated REST request with Python

Complete noobie question here. I'm trying to access the REST API for ExactTarget to access Campaign data and open / clicks etc using Python

I have installed the FuelSDK and can perform requests such as those found on GIT here.

This post references the REST/SOAP api to connect campaigns with clickers.

Can anyone tell me how to access the REST urls in Python?

Best Answer

Please read exacttarget api reference

You couldn't access resources without authorization. First you should request for an Access Token:

import json, requests


payload = {
    'clientId': client_Id,
    'clientSecret': client_Secret

url = "https://auth.exacttargetapis.com/v1/requestToken";

r = requests.post(url,

body = json.loads(r.content)
token = body["accessToken"]
expiresIn = body["expiresIn"]
print token

Now you can access your resources using Access Token:

url="https://www.exacttargetapis.com/hub/v1/campaigns?$page=1&$pageSize=2&$orderBy=Name ASC"

r = requests.get(url, headers = {"Authorization":"Bearer " + token})
print r.content

Before using Python, I recommend you to try Postman, it will help you to understand requests etc.

Related Topic