37 lines
1.0 KiB
Python
37 lines
1.0 KiB
Python
import requests
|
|
import Apikeys
|
|
import pprint
|
|
|
|
|
|
PP = pprint.PrettyPrinter(indent=4)
|
|
APIKEY = Apikeys.SANDBOX
|
|
HEADERS = {"content-type": "application/json", "X-Api-Key": APIKEY}
|
|
BASEURL = "https://api.northpass.com/v2"
|
|
|
|
|
|
def get(url):
|
|
try:
|
|
get_response = requests.get(url, headers=HEADERS)
|
|
# print(f"Executed Get Request. Status code is {get_response.status_code}")
|
|
except HTTPError as h:
|
|
print(
|
|
f"Error occurred. Here's the info: {h} and status code: {get_response.status_code}"
|
|
)
|
|
finally:
|
|
json_get = get_response.json()
|
|
# PP.pprint(json_get)
|
|
return json_get
|
|
|
|
|
|
def post(url, payload):
|
|
try:
|
|
post_response = requests.get(url, headers=HEADERS, json=payload)
|
|
print(f"Executed Post Request. Status code is {get_response.status_code}")
|
|
except HTTPError as h:
|
|
print(
|
|
f"Error occurred. Here's the info: {h} and status code: {get_response.status_code}"
|
|
)
|
|
finally:
|
|
json_post = get_response.json()
|
|
# PP.pprint(json_post)
|