SJ api calls folder. Added a script for DeepL.
This commit is contained in:
Binary file not shown.
47
Scripts/API_Tests/get_all_people_toggle_prop.py
Normal file
47
Scripts/API_Tests/get_all_people_toggle_prop.py
Normal file
@ -0,0 +1,47 @@
|
||||
import requests
|
||||
import Apikeys
|
||||
import pprint
|
||||
|
||||
|
||||
|
||||
pp=pprint.PrettyPrinter(indent=4)
|
||||
APIKEY = Apikeys.DEEPL
|
||||
BASEURL = "https://api.northpass.com/v2"
|
||||
HEADERS = {
|
||||
"accept": "application/json",
|
||||
"X-Api-Key": APIKEY
|
||||
}
|
||||
|
||||
def get_people():
|
||||
count = 0
|
||||
while True:
|
||||
ppl_uuids = []
|
||||
url = f"{BASEURL}/people?page={count}&limit=100"
|
||||
print(url)
|
||||
count += 1
|
||||
response = requests.get(url, headers=HEADERS).json()
|
||||
for data in response['data']:
|
||||
person_uuid = data['id']
|
||||
ppl_uuids.append(person_uuid)
|
||||
if len(ppl_uuids) == 10:
|
||||
print(len(ppl_uuids))
|
||||
apply_prop(ppl_uuids)
|
||||
# break
|
||||
|
||||
def apply_prop(ppl_uuids):
|
||||
inserted_load = []
|
||||
for person in ppl_uuids:
|
||||
print(person)
|
||||
miniload = {
|
||||
"attributes": { "properties": { "new_content": "true" } },
|
||||
"id": person,
|
||||
"type": "person_properties"
|
||||
}
|
||||
inserted_load.append(miniload)
|
||||
prop_url = f"{BASEURL}/properties/people/bulk"
|
||||
payload = { "data": inserted_load }
|
||||
print(payload)
|
||||
# apply_payload = requests.posts(prop_url, json=payload, headers=HEADERS)
|
||||
|
||||
if __name__ == "__main__":
|
||||
get_people()
|
||||
Reference in New Issue
Block a user