Skip to content Skip to sidebar Skip to footer

Why Am I Getting 500 Internal Server Error When Calling Post Rest Api Via Python Request?

I'm trying to call a post rest API using python requests library. I'm able to get a proper response when I request using postman. When I tried to call it using python request libra

Solution 1:

Remove the payload parameter and add files. Refer to requests documentation which explains this option of requests.request function.

import requests

url = "http://192.188.9.146:9886/getcontext/"

files = {'file': open('PATH_TO_FILE\Go_To_Setting_Screen.jpg','rb')}
data  = {'project': 'daynight'}

response = requests.request("POST", url, files = files, data = data)

print(response.text)

Post a Comment for "Why Am I Getting 500 Internal Server Error When Calling Post Rest Api Via Python Request?"