Instantly share code, notes, and snippets.

Embed
What would you like to do?
def make_request(path, method, payload=None):
# Use API Key and API Token that you've copied from
# your settings page.
headers = {
'apikey': 'apidemo@prisync.com',
'apitoken': 'c18888888888888888888fa135f540',
}
# This is the root URL. All API calls are relative to this URL.
base_url = "https://prisync.com/api/v2"
# We append the path into base_url
url = "".join([base_url, path])
# HTTP GET for getting data
if method == 'get':
result = requests.get(url, headers=headers)
# HTTP POST for usually creating new data and editing data.
elif method == 'post':
result = requests.post(url, data=payload, headers=headers)
else:
raise NotImplementedError
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment