Last active
August 14, 2018 17:49
-
-
Save djpillen/4dd8f3b2e4672a1874c8ac8c646037db to your computer and use it in GitHub Desktop.
Add new enumeration values to an ArchivesSpace enumeration
This file contains 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 | |
username = "username" | |
password = "password" | |
aspace_url = "http://localhost:8089" | |
authenticate = requests.post("{}/users/{}/login?password={}".format(aspace_url, username, password)).json() | |
token = authenticate["session"] | |
headers = {"X-ArchivesSpace-Session":token} | |
# subject_source enumeration | |
enumeration_id = "23" | |
new_values = ["lcnaf", "lctgm"] | |
enumeration = requests.get("{}/config/enumerations/{}".format(aspace_url, enumeration_id), headers=headers).json() | |
enumeration["values"].extend(new_values) | |
requests.post("{}/config/enumerations/{}".format(aspace_url, enumeration_id), data=json.dumps(enumeration), headers=headers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment