Created
December 28, 2017 12:28
-
-
Save prisync/58ef8c58d46d80c561b543db65ffe6ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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