Files
Gainsight/Scripts/API_Tests/getuuid_from_email.py

66 lines
1.9 KiB
Python
Raw Normal View History

2022-11-08 14:47:53 -05:00
import requests
2022-11-21 16:08:13 -05:00
baseUrl = "https://api.northpass.com/v2/people/"
2022-11-08 14:47:53 -05:00
baseUrlname = "https://api.northpass.com/v2/people?filter[name][eq]="
baseUrlemail = "https://api.northpass.com/v2/people?filter[email][eq]="
2022-11-11 21:54:43 -05:00
apiKey = "JRDpCGQ7vSRiva6t5OkWDr5eJ" #G2
#apiKey = "6hUfJdAartHTHhHc0WIRZYPWe" #Walmart
2022-11-08 14:47:53 -05:00
def getfromName(baseUrlname, apiKey):
2022-11-21 16:08:13 -05:00
name = "Someone else"
2022-11-08 14:47:53 -05:00
url = baseUrlname + f"{name}"
headers = {
"accept": "*/*",
"x-api-key": apiKey,
"content-type": "application/json",
}
response = requests.get(url, headers=headers)
2022-11-21 16:08:13 -05:00
if response.status_code == 200:
print("200 Response!")
else:
print("Another error! " + response.status_code)
2022-11-08 14:47:53 -05:00
response = response.json()
2022-11-21 16:08:13 -05:00
#print(response)
#uuid = response["data"][0]["id"]
#print("Learner ID:" )
#print(uuid)
2022-11-08 14:47:53 -05:00
def getfromEmail(baseUrlemail, apiKey):
2022-11-21 16:08:13 -05:00
#email = "norm2test@northpass.com" # The %2B encodes the + sign in the URL. Using the + sign won't work.
email = " "
2022-11-08 14:47:53 -05:00
url = baseUrlemail + f"{email}"
2022-11-11 21:54:43 -05:00
print(url)
2022-11-08 14:47:53 -05:00
headers = {
"accept": "*/*",
"x-api-key": apiKey,
"content-type": "application/json",
}
response = requests.get(url, headers=headers)
print(response)
2022-11-21 16:08:13 -05:00
if response.status_code == 200:
print("200 Error!")
else:
print("Another Error!")
response = response.json()
#print(response)
2022-11-11 21:54:43 -05:00
uuid = response["data"]
2022-11-21 16:08:13 -05:00
#print("Learner ID:" )
#print(uuid)
def getfromUuid(baseUrl, apiKey):
uuid = "57b2b5eb-aa56-4cee-bb32-8c678a2de1b7"
url = baseUrl + uuid
headers = {
"accept": "*/*",
"x-api-key": apiKey,
"content-type": "application/json",
}
response = requests.get(url, headers=headers)
print(response.status_code)
print(response.text)
2022-11-08 14:47:53 -05:00
if __name__ == "__main__":
2022-11-21 16:08:13 -05:00
getfromUuid(baseUrl, apiKey)
#getfromEmail(baseUrlemail, apiKey)
2022-11-11 21:54:43 -05:00
#getfromName(baseUrlname, apiKey)