[Archivesspace_Users_Group] partially update a record through API

Mang Sun mang.sun at rice.edu
Tue Dec 2 10:40:44 EST 2014


Chris,

The script runs as expected. Thanks a lot.

Mang
On 11/26/2014 4:10 AM, Chris Fitzpatrick wrote:
>
> Sorry, just realized I sent the git url. Here's the gist:
>
>
> https://gist.github.com/cfitz/9eb97ad3f6dd772f875f
>
>
>
>
> Chris Fitzpatrick | Developer, ArchivesSpace
> Skype: chrisfitzpat  | Phone: 918.236.6048
> http://archivesspace.org/
>
> ________________________________________
> From: Chris Fitzpatrick
> Sent: Wednesday, November 26, 2014 11:09 AM
> To: Archivesspace Users Group
> Subject: Re: [Archivesspace_Users_Group] partially update a     record  through API
>
> Hi,
>
> Ok, so have a look at this rather rough script :
>
> https://gist.github.com/9eb97ad3f6dd772f875f.git
>
> It's in Ruby, and you'll have to have rest_client and highline installed ( gem install rest_client highline )
>
> Run this with a file called template.json with the values you want to have added. You provide your URI, user, password, repository, and the type of record you're wanting to change. This will go through, get the record's json, merge in the json from your template.json, and update the record.
>
> Let me know if you have any questions...and fyi global replace features are expected to be done during a sprint in early 2015.
>
> best, chris.
>
>
> Chris Fitzpatrick | Developer, ArchivesSpace
> Skype: chrisfitzpat  | Phone: 918.236.6048
> http://archivesspace.org/
>
> ________________________________________
> From: archivesspace_users_group-bounces at lyralists.lyrasis.org <archivesspace_users_group-bounces at lyralists.lyrasis.org> on behalf of Steven Majewski <sdm7g at virginia.edu>
> Sent: Tuesday, November 25, 2014 6:04 PM
> To: Archivesspace Users Group
> Subject: Re: [Archivesspace_Users_Group] partially update a     record  through API
>
> jq would be handy here:
> http://stedolan.github.io/jq/
>
> something like:
> GET some object with curl |  jq edit | PUT same object with curl
>
> where you pass in object URI and jq edit command.
>
> It would only work for objects where there was a symmetrical GET & PUT.
> ( i.e. not for  GET /repositories/$REPO/resources/$ID )
>
>
> — Steve.
>
>
> On Nov 25, 2014, at 10:06 AM, Kevin Clair <Kevin.Clair at du.edu> wrote:
>
>> Hello,
>>
>> I'd be interested as well. I've written one already, which I can share if there's interest, but it's written for very specific migration tasks that we have here at DU so it might not be the most efficient way of going about this.  -k
>>
>> -----Original Message-----
>> From: archivesspace_users_group-bounces at lyralists.lyrasis.org [mailto:archivesspace_users_group-bounces at lyralists.lyrasis.org] On Behalf Of Noah Huffman
>> Sent: Tuesday, November 25, 2014 7:27 AM
>> To: Archivesspace Users Group
>> Subject: Re: [Archivesspace_Users_Group] partially update a record through API
>>
>> Hi Chris,
>>
>> If you write this script, could you share with the list?  I'd be interested as well.
>>
>> I expect that these sorts of batch editing tasks will be fairly common.
>>
>> Thanks,
>> -Noah
>>
>> ================
>> Noah Huffman
>> Archivist for Metadata and Encoding
>> David M. Rubenstein Rare Book & Manuscript Library Duke University http://library.duke.edu/rubenstein/
>>
>>
>>
>> -----Original Message-----
>> From: archivesspace_users_group-bounces at lyralists.lyrasis.org [mailto:archivesspace_users_group-bounces at lyralists.lyrasis.org] On Behalf Of Chris Fitzpatrick
>> Sent: Tuesday, November 25, 2014 8:59 AM
>> To: archivesspace_users_group at lyralists.lyrasis.org
>> Subject: Re: [Archivesspace_Users_Group] partially update a record through API
>>
>>
>> Hi Mang Sun,
>>
>>
>> If you're doing it this way, you'll need to get the JSON first and add the publish: false value, then POST that back.
>>
>> I can write a small script for you that does this, if you're interested...
>> b,chris
>>
>> Chris Fitzpatrick | Developer, ArchivesSpace
>> Skype: chrisfitzpat  | Phone: 918.236.6048 http://archivesspace.org/
>>
>> ________________________________________
>> From: archivesspace_users_group-bounces at lyralists.lyrasis.org <archivesspace_users_group-bounces at lyralists.lyrasis.org> on behalf of Mang Sun <mang.sun at rice.edu>
>> Sent: Thursday, November 20, 2014 6:34 PM
>> To: archivesspace_users_group at lyralists.lyrasis.org
>> Subject: [Archivesspace_Users_Group] partially update a record through API
>>
>> I am trying to partially update accession records by setting PUBLISH to false using REST API, but I can't get it done successfully.
>> For example, run the following command to update one accession record, curl_as username password -d "@accession.json" -v "the AS API url/repositaries/2/accession/1"
>>
>> accession.json contains
>> {
>> "publish" : false
>> }
>>
>> but I get the following complaints
>>
>> {"error":{"id_0":["Property is required but was missing"],"accession_date":["Property is required but was
>> missing"]},"warning":null,"invalid_object":"#<JSONModel(:accession)
>> {\"publish\"=>true, \"jsonmodel_type\"=>\"accession\",
>> \"external_ids\"=>[], \"related_accessions\"=>[], \"subjects\"=>[], \"linked_events\"=>[], \"extents\"=>[], \"dates\"=>[], \"external_documents\"=>[], \"rights_statements\"=>[], \"deaccessions\"=>[], \"related_resources\"=>[], \"restrictions_apply\"=>false, \"access_restrictions\"=>false, \"use_restrictions\"=>false, \"linked_agents\"=>[], \"instances\"=>[]}>"}
>>
>>
>> Any idea?
>>
>> Mang Sun
>> Rice U.
>>
>> _______________________________________________
>> Archivesspace_Users_Group mailing list
>> Archivesspace_Users_Group at lyralists.lyrasis.org
>> http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group
>> _______________________________________________
>> Archivesspace_Users_Group mailing list
>> Archivesspace_Users_Group at lyralists.lyrasis.org
>> http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group
>> _______________________________________________
>> Archivesspace_Users_Group mailing list
>> Archivesspace_Users_Group at lyralists.lyrasis.org
>> http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group
>>
>> _______________________________________________
>> Archivesspace_Users_Group mailing list
>> Archivesspace_Users_Group at lyralists.lyrasis.org
>> http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group
> _______________________________________________
> Archivesspace_Users_Group mailing list
> Archivesspace_Users_Group at lyralists.lyrasis.org
> http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group
>




More information about the Archivesspace_Users_Group mailing list