Files
Gainsight/Scripts/API_Tests/api_test.py
2023-02-15 17:08:29 -05:00

57 lines
1.5 KiB
Python

import requests
import Apikeys
# url ="https://api.northpass.com/v2/groups/e6ef3e5f-b5a2-4b10-868b-8c165d76d263/learning_paths"
url = "https://api.northpass.com/v1/media"
# function = sys.argv[1]
apiKey = Apikeys.talkspace_core
# Get Group Memberships:
# url = "https://api.northpass.com/v2/groups/504c4771-223a-447f-9ec6-08e51bc9ca23/memberships"
def putTest(apiKey, url):
payload = {
"data": {
"type": "media",
"file_name": "/Users/normrasmussen/Downloads/Shopping&Delivery 9 XP.mp4",
}
}
headers = {
"accept": "application/json",
"content-type": "application/json",
"X-Api-Key": apiKey,
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)
def getTest(apiKey, url):
print(url)
print(apiKey)
headers = {"accept": "application/json", "X-Api-Key": apiKey}
response = requests.get(url, headers=headers)
# print(response.text)
jsonResponse = response.json()
print(jsonResponse)
# print(jsonResponse["included"][1]["attributes"]["email"])
# print(jsonResponse["data"][1]["attributes"])
def postTest(apiKey, url):
headers = {
"accept": "application/json",
"content-type": "application/json",
"X-Api-Key": apiKey,
}
response = requests.post(url, headers=headers)
print(response.text)
if __name__ == "__main__":
getTest(apiKey, url)
# putTest(apiKey, url)
# postTest(apiKey, url):