Issue with Post to API using Python

Issue with Post to API using Python

Hi Folks,  I'm having issues with creating a request in SDP through the API using Python and was hoping someone could help.  I've managed to get a working test script but if I try and put any variables into the input_data block then I just get invalid syntax errors.

Basically, I'm trying to change the 'subject':'test' to a variable from another source so I'd expect it to be 'subject':'",variable",' or something similar.  I'm new to SDP and python so happy to start again if there's a better way of doing it.  Any advice gratefully received.

Thanks  :)


import requests
import json

headers = {
'Accept': 'application/vnd.manageengine.sdp.v3+json',
'content-type': 'application/x-www-form-urlencoded',
'Authorization': 'Zoho-oauthtoken 1000.xxxxxxxx'
}

data = "input_data=\
{\
'request':{\
'subject':'test'}\
}"

def jprint(obj):
   # create a formatted string of the Python JSON object
  text = json.dumps(obj, sort_keys=True, indent=4)
  print(text)

response = requests.post("https://sdpondemand.manageengine.eu/api/v3/requests", headers=headers, data= data)
jprint(response.json())

                New to ADSelfService Plus?