Skip to content

Instantly share code, notes, and snippets.

@vladwa
Last active December 30, 2017 11:48
Show Gist options
  • Save vladwa/78c280501a3d3d232ec9697bf436d643 to your computer and use it in GitHub Desktop.
Save vladwa/78c280501a3d3d232ec9697bf436d643 to your computer and use it in GitHub Desktop.
Python code to make HTTP post request. This function returns Response object.
# importing the requests library
import requests
def getPostRestResponse(restUrl,inputRequest,contentType):
"""Sends a POST request.
:param url: URL for the new :class:`Request` object.
:param inputRequest: Data to send in the body of the request.
:return: :class:`Response <Response>` object.
"""
content = {'content-type': contentType}
response = requests.post(restUrl, inputRequest, headers=content)
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment