[Archivesspace_Users_Group] Using the API from perl - "Must be a JSONModel(:resource) uri (you provided a Hash)"
Alan Manifold
amanifold at slv.vic.gov.au
Mon Nov 25 22:12:33 EST 2019
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<http://slv.vic.gov.au>
[https://www.slv.vic.gov.au/sites/default/files/email_signature/signature.jpg?9]<https://www.slv.vic.gov.au/email_campaign>
[follow us]
[SLV facebook]<http://www.facebook.com/pages/Melbourne-Australia/State-Library-of-Victoria/32256104331> [SLV twitter] <http://twitter.com/Library_Vic> [SLV youtube] <http://www.youtube.com/user/statelibraryvictoria> [SLV instagram] <http://instagram.com/library_vic> [Gold Winner 2018 RACV Victorian Tourism Awards] [MEA Awards 2018 National Winner]
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20191126/157eae29/attachment.html>
More information about the Archivesspace_Users_Group
mailing list