0

When I try to access the Eloqua API with the following code, I get a 400 error. Eloqua Support tells me the following:

"It seems that the 400 error is being caused by an unfamiliar format being using in the request's body. We suggest using the JSON form at advised."

Is there something about this call that is not putting the call body in JSON format? How can I do that?

auth = auth_string.encode('base64','strict')

url='https://secure.p03.eloqua.com/api/bulk/2.0/activities/exports'
data= {"name":"Activity Export Test", 
"fields":{
      "ActivityId":"{{Activity.Id}}",
   }, 
"filter":"'{{Activity.Type}}'='Subscribe'"}
data2 = json.dumps(data)
headers = {'Authorization': "Basic %s" % auth}
r =  requests.post(url, data=data2, headers=headers)
mcseare
  • 3
  • 1
  • have you tried useing the header: 'Content-type': "application/json", alongside the authorization header. – Kutoff Jan 30 '15 at 16:01
  • Did you try `print data2` to check if the data is formatted right before passing to api – Paul Lo Jan 30 '15 at 16:02

1 Answers1

2

You are missing the Content-Type header. Try adding it, like so:

headers = {
    "Authorization": "Basic %s" % auth,
    "Content-Type": "application/json"
}
nofinator
  • 2,906
  • 21
  • 25