I'm trying perform a POST request with a JSON payload in Python but nothing happens when I run my script:
I have my payload:
newTicket = {
"subject": "Testing POST API request",
"person": 749,
"department": 1,
"X-DeskPRO-API-Key": "API KEY",
"Authorization": "API KEY"
}
and my POST request (URL and API keys removed):
postResponse = requests.post("url.com", json = newTicket,
headers={
"Content-Type": "application/json",
"Accept": "application/json",
"X-DeskPRO-API-Key": "API KEY",
"Authorization": "API KEY"
}
)
Nothing happens when I check my software, is my json payload formatted properly? What am I doing wrong here?
When I print the response with:
print(postResponse.status_code)
I get:
200
And when I check my software's API call log, nothing relating to my POST request is there.
When I check the request body with:
print(postResponse.request.body)
I get:
None
Status 200 means the request worked and returned no error. Check the response like this
print(postResponse.json())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.