Created
November 14, 2019 15:45
-
-
Save kschlottmann/8218d616eed0d61f3b8c0f3f0efac313 to your computer and use it in GitHub Desktop.
delete all locations from AS test server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import requests | |
| import secretsTest | |
| import time | |
| import os | |
| startTime = time.time() | |
| #call secrets for authentication | |
| baseURL = secretsTest.baseURL | |
| user = secretsTest.user | |
| password = secretsTest.password | |
| #authenticate session | |
| auth = requests.post(baseURL + '/users/'+user+'/login?password='+password).json() | |
| session = auth["session"] | |
| headers = {'X-ArchivesSpace-Session':session, 'Content_Type':'application/json'} | |
| print 'authenticated' | |
| print baseURL | |
| #define the API call to get a list of all locations | |
| endpoint_1 = '//locations?all_ids=true' | |
| #call the API | |
| ids = requests.get(baseURL + endpoint_1, headers=headers).json() | |
| #iterate over each returned ID, deleting the location | |
| for id in ids: | |
| endpoint_2 = '//locations/'+str(id) | |
| output = requests.delete(baseURL + endpoint_2, headers=headers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment