Files
Gainsight/Scripts/API_Tests/getuuid_from_email.py
2022-11-11 21:54:43 -05:00

44 lines
1.3 KiB
Python

import requests
import urllib.parse
baseUrlname = "https://api.northpass.com/v2/people?filter[name][eq]="
baseUrlemail = "https://api.northpass.com/v2/people?filter[email][eq]="
apiKey = "JRDpCGQ7vSRiva6t5OkWDr5eJ" #G2
#apiKey = "6hUfJdAartHTHhHc0WIRZYPWe" #Walmart
def getfromName(baseUrlname, apiKey):
name = "Norm Test Testing Norm"
url = baseUrlname + f"{name}"
headers = {
"accept": "*/*",
"x-api-key": apiKey,
"content-type": "application/json",
}
response = requests.get(url, headers=headers)
response = response.json()
print(response)
uuid = response["data"][0]["id"]
print("Learner ID:" )
print(uuid)
def getfromEmail(baseUrlemail, apiKey):
email = "norm%2Bg2test@northpass.com" # The %2B encodes the + sign in the URL. Using the + sign won't work.
#email = "aaron.rodgers@corpay.com"
url = baseUrlemail + f"{email}"
print(url)
headers = {
"accept": "*/*",
"x-api-key": apiKey,
"content-type": "application/json",
}
response = requests.get(url, headers=headers)
response = response.json()
print(response)
uuid = response["data"]
print("Learner ID:" )
print(uuid)
if __name__ == "__main__":
getfromEmail(baseUrlemail, apiKey)
#getfromName(baseUrlname, apiKey)