I am attempting to improve my python by working on a side-project, just interacting with websites to look at avaialble golf tee times. Zero intention/plans to do anything commercial, this is just a semi-practical way to learn more about the requests library and web site/api interaction.
If I use the same URL, headers, and JSON payload, I get back two different results. In both cases I get status 200, but using postman, the result body is json data of available tee times for a given date and golf course.
If I post the same request using python, I get back html/website data and not the JSON. I've attempted as much debugging as I can, like verifying the headers and body are set the same for both requests. Also no authorization is being used in either postman or python. What else can I check or how can I test this further?
Im including code of the API/website request, as well as screenshots from Postman.
for course, id in golfback_courses.items():
gc_url = "https://api.golfback.com/api/v1/courses/" + id + "/date/" + golf_date + "/teetimes?utm_source=drumm_farm_website&utm_medium=button&utm_campaign=tee_times"
headers = {"Content-Type": "application/json; charset=utf-8"}
payload = json.dumps({'sessionId': None})
print(f"Tee Times for {course} on {golf_date}: ")
response = requests.post(gc_url, headers=headers, json=payload, allow_redirects=True)
#debugging prints and checking status codes
print(response.status_code)
print(dump.dump_all(response).decode("utf-8"))
html_content = response.content
print(type(html_content))
soup = BeautifulSoup(html_content, "html.parser")
#additional json/text manipulation and print logic once I verify I have json object
I'm also attaching a screenshot of the request and body response from postman. Im showing the headers, which for the exception of the Postman-Token, I verified all are the same on the python side, or, disabled them in postman and verified I still get the same response. The body is simply raw JSON passing in a null sessionId, i.e. {"sessionId": null}. I verified via json.dumps that the {'sessionId': None} in python encodes to sessionId: null.
Any further troubleshooting help is appreciated.

requestshas different headerUser-Agentthanpostmanorcurland sometimes it makes difference.postamanhas function to generate code in different languages - there is alsoPythonwithrequests. You may check if it will generate the same code as you created.json={'sessionId': None}withoutjson.dumps()postmanandPythontohttpbin.org/postand it will send you back all your headers, cookies, etc. and you can compare if both sends the same values. You may also try to use local proxy server like Charlies or mitmproxy to see what sendpostman(if you use local application) andPython