Skip to content

Instantly share code, notes, and snippets.

@prisync
Created December 28, 2017 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prisync/58ef8c58d46d80c561b543db65ffe6ac to your computer and use it in GitHub Desktop.
Save prisync/58ef8c58d46d80c561b543db65ffe6ac to your computer and use it in GitHub Desktop.
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