Skip to content

Instantly share code, notes, and snippets.

@kschlottmann
Created November 14, 2019 15:45
Show Gist options
  • Select an option

  • Save kschlottmann/8218d616eed0d61f3b8c0f3f0efac313 to your computer and use it in GitHub Desktop.

Select an option

Save kschlottmann/8218d616eed0d61f3b8c0f3f0efac313 to your computer and use it in GitHub Desktop.
delete all locations from AS test server
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