[Archivesspace_Users_Group] Using the API from perl - "Must be a JSONModel(:resource) uri (you provided a Hash)"

Brian Harrington brian.harrington at lyrasis.org
Mon Nov 25 22:54:59 EST 2019


Hi Alan,

You ought to be able to add the resource reference to your archival object hash as another hash, like:

resource => {ref => "/repositories/3/resources/391”}

If that’s not working, I’d be happy to take a look at your code if you want to send it to me directly.

Brian


> On Nov 25, 2019, at 10:12 PM, Alan Manifold <amanifold at slv.vic.gov.au> wrote:
> 
> Hi all,
> I'm trying to create a perl program to add archival_objects and digital_objects into our ArchivesSpace system. I can query the database fine, and I seem to be able to get to the right API, but I can't seem to find any combination that allows me to embed a "resource" reference into my JSON for the post call.
> 
> I have gotten a variety of errors, but they are all telling me that the way I have specified the "resource/ref" is invalid, for example:
> 
> 'resource/ref' => 'Must be a JSONModel(:resource) uri (you provided a Hash) (malformed or invalid uri? check if referenced object exists.)'
>> I am assuming the real problem is that I "provided a Hash", not the "malformed or invalid uri", but in case it's relevant, the uri looks like this: "/repositories/3/resources/391".
> 
> I am defining the archival_object as a perl hash, with the various JSON elements as hash entries, e.g.:
> 
>     my %archival_object =
>     (
>         jsonmodel_type          =>  "archival_object",
>         subjects                =>  [],
>         linked_events           =>  [],
>         extents                 =>  [],
>         lang_materials          =>  [],
>         ...
>     );
> 
> I was able to specify the "dates", "notes", and "external_ids" sections as arrays with a hash as their only value, and that seems to work:
> 
>         dates                   =>
>         [
>             {
>                 expression          =>  $rosDate,
>                 date_type           =>  "inclusive",
>                 label               =>  "creation",
>                 jsonmodel_type      =>  "date"
>             }
>         ],
> 
> But I haven't been able to find any way to specify the "resource" section in such a way that the API recognises my "ref" value. I have tried lots of ways, but always get one of these errors:
>> 'resource' => 'Property is required but was missing'
> 'resource' => 'Must be a object (you provided a String)'​
> 'resource/ref' => 'Must be a JSONModel(:resource) uri (you provided a Hash) (malformed or invalid uri? check if referenced object exists.)'​​​
> 'resource/ref' => 'Must be a JSONModel(:resource) uri (you provided a String) (malformed or invalid uri? check if referenced object exists.)'​
> 'resource/ref' => 'Must be a JSONModel(:resource) uri (you provided a Array) (malformed or invalid uri? check if referenced object exists.)'​​
>> I can't think of any other data types, pointers, or combinations that I can try, and I don't know what the API is looking for. I even tried doing a search to get a Resource record and plugging the result directly into my archival_object structure, but that didn't change anything.
> 
> How can I define my archival_object structure so that it will validate? Unfortunately, using python or ruby in place of perl probably isn't an option. I'm happy to provide more information, including more of my code, but didn't want to spam everybody with it.
> 
> Regards,
> Alan Manifold
> State Library Victoria
> 
> Alan Manifold | Library Systems & Digital Preservation Manager | Collection Development & Description 
> State Library Victoria | 328 Swanston Street | Melbourne VIC 3000 
> T +61 3 8664 7122 | amanifold at slv.vic.gov.au 
> slv.vic.gov.au
> 
> 	
> 
> 					 	
> This message and any attachment is intended only for the use of the Addressee and may contain information that is PRIVILEGED and CONFIDENTIAL. If you are not the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please delete all copies of the message and its attachments and notify the sender immediately. Thank you. _______________________________________________
> 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