Search code examples
pythonxmlpython-requestspostman

Api Test : Postman vs Python Requests


I could send post request using postman, but I it fails with python requests library:

headers = {'Content-Type': 'application/xml'}
r = requests.post(url, data=xml, headers=headers)

Why postman test is ok? What is the difference between Postman and python request post?


Solution

  • OK - Just to answer the question as the original link by @OluwafemiSule now returns 404. In Postman, on the upper right hand side just below the "Send" pull down is a small text button labeled "Code". Press that and you can chose to see the transmission coded to run in a large number of languages - including python/requests. An updated link as of 02/2019: https://learning.getpostman.com/docs/postman/sending_api_requests/generate_code_snippets/#___gatsby