Files
Gainsight/Scripts/API_Tests/getuuid_from_email.py

71 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]="
2023-01-05 17:15:12 -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! ")
print(response.status_code)
2022-11-08 14:47:53 -05:00
response = response.json()
2023-01-05 17:15:12 -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):
2023-01-05 17:15:12 -05:00
# email = "norm2test@northpass.com" # The %2B encodes the + sign in the URL. Using the + sign won't work.
2022-11-21 16:08:13 -05:00
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()
2023-01-05 17:15:12 -05:00
# print(response)
2022-11-11 21:54:43 -05:00
uuid = response["data"]
2023-01-05 17:15:12 -05:00
# print("Learner ID:" )
# print(uuid)
2022-11-21 16:08:13 -05:00
def getfromUuid(baseUrl, apiKey):
uuid = "57b2b5eb-aa56-4cee-bb32-8c678a2de1b7"
url = baseUrl + uuid
headers = {
"accept": "*/*",
"x-api-key": apiKey,
"content-type": "application/json",
2023-01-05 17:15:12 -05:00
}
2022-11-21 16:08:13 -05:00
response = requests.get(url, headers=headers)
print(response.status_code)
print(response.text)
2022-11-08 14:47:53 -05:00
2023-01-05 17:15:12 -05:00
2022-11-08 14:47:53 -05:00
if __name__ == "__main__":
2022-11-21 16:08:13 -05:00
getfromUuid(baseUrl, apiKey)
2023-01-05 17:15:12 -05:00
# getfromEmail(baseUrlemail, apiKey)
# getfromName(baseUrlname, apiKey)