Unable to POST via the API with ArchivesSpace 4.1

428 views
Skip to first unread message

Lynn Moulton

unread,
Aug 11, 2025, 4:42:22 PMAug 11
to Archivesspac...@lyrasislists.org
Hello brain trust,

My institution recently updated our test instance of ArchivesSpace to 4.1, and a colleague and I are both experiencing an odd behavior with python scripts run on the API. We are not using ArchiveSnake, just freestanding scripts. In each case, the GET command in the script is successfully fetching the expected json from the endpoint. The POST doesn't throw any errors, but the data in ArchivesSpace remains unchanged. However, running the same scripts on our production instance, which is still on 3.5, works. It feels like a possible permissions problem, but my user account has full permissions.

Is anyone else experiencing this behavior? 

Best,
Lynn Moulton
Processing Archivist
John J. Burns Library
Boston College

Michelle Paquette

unread,
Aug 12, 2025, 10:08:23 AMAug 12
to Lynn Moulton, Archivesspac...@lyrasislists.org
Lynn I've had the same issue using scripts that run on my former colleague's ASpace module (on github here, documentation here). Scripts using this module rather than ASnake work perfectly fine in our 3.5.1 production instance, but fail on our test instance. The only error I seem to be getting is "{'error': "Had some trouble parsing your request: unexpected token at ''"}. My JSON object I'm trying to post is valid so I'm not sure what the trouble is with 4.1 vs. 3.5. If anyone else out there has answers or has experienced this, please let me know! I've just been attempting to convert all my scripts to use ASnake instead (which, to be fair, is probably for the best given that the colleague who wrote our module no longer works here haha).

Michelle

--
You received this message because you are subscribed to the Google Groups "Archivesspace_Users_Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to Archivesspace_User...@lyrasislists.org.
To view this discussion visit https://groups.google.com/a/lyrasislists.org/d/msgid/Archivesspace_Users_Group/CAHXNEzrsQSbJt%2BjddzkHVjooJuTXF1nXQE8-gDo0CENcZS38dw%40mail.gmail.com.


--
Michelle Paquette
(she/her)
Metadata & Technical Services Archivist
Special Collections
Smith College

Valerie Addonizio

unread,
Aug 12, 2025, 2:37:45 PMAug 12
to Michelle Paquette, Lynn Moulton, Archivesspac...@lyrasislists.org

I wonder…

 

I have a recent-ish memory that I had an issue with how to encode the payload and I think it only happened to me when 4.0.0 came out. This might not apply to Lynn’s scenario because there were no errors, but it may apply to Michelle. I helped another user with it, which helped confirm it was happening for me. I use requests, so this may not be relevant to all of you, but I had to switch from using json.dumps in the POST. Credit to Julia C. on code4lib slack, where she provided a Before and After example after we chatted, which I’ve modified below.

 

Before:

data = requests.post(baseURL + uri, headers=headers,data=json.dumps(data_that_is_a_python_dictionary_or_list)).json()

 

After:

data = requests.post(baseURL + uri, headers=headers, json=data_that_is_a_python_dictionary_or_list).json()

 

If it’s this same issue, it might also be solved by being more explicit in setting the content-type parameter in the header to application/json

 

This was definitely an issue for me, I just don’t know if it’s the same issue.

Lynn Moulton

unread,
Aug 12, 2025, 3:22:49 PMAug 12
to Valerie Addonizio, Michelle Paquette, Archivesspac...@lyrasislists.org
Thank you Valerie! This was, in fact, our problem. I'm not clear on why it wasn't producing an error in my original script, but removing the .dumps and reformatting the data following Valerie's example resulted in a valid POST. As always, very appreciative for the listserv collective problem-solving. ♥️

Best,
Lynn M. 

Regine I. Heberlein

unread,
Aug 15, 2025, 5:13:24 PMAug 15
to Lynn Moulton, Valerie Addonizio, Michelle Paquette, Archivesspac...@lyrasislists.org
In case this helps another Ruby/archivesspace-client person out there, I ran into a similar (possibly the same?) issue, and it caught me totally sideways. In my case, I was unable to post both to our 3.5.1 instance AND our 4.1.1 instance, which may help explain why it also took me a full day to realize that it IS related (thanks Jen and Blake for your assistance!)

I had until now been posting Ruby hashes that I passed to the .to_json method, but now I have to pass them directly or the post fails with the most obnoxiously confusing jsonmodel type error ("{"error":"undefined method `keys' for #<String:0x7ea896cb>: uri:classloader:/jsonmodel_type.rb:192” and about two more miles of text).

My BEFORE: @client.post(uri, record.to_json)
My AFTER: @client.post(uri, record)

Hope this helps someone.

Cheers,

-Regine

Regine Heberlein (she/her)

Archival Systems Technical Lead

hebe...@princeton.edu

 

**My working day may not be your working day. Please do not feel obliged to reply to this email outside of your regular working hours.**

 

 

Elizabeth Peters

unread,
Aug 18, 2025, 1:46:42 PMAug 18
to Regine I. Heberlein, Lynn Moulton, Valerie Addonizio, Michelle Paquette, Archivesspac...@lyrasislists.org
I think these two issues are almost definitely related, because I've now run into them both, on our 4.1 test instance. I was having the same posting issue as Lynn and Michelle, with the parsing error message ("error": "Had some trouble parsing your request: unexpected token at ''"). I updated it to the fix Valerie suggested, which resolved that error, but the data still didn't actually post. I asked it to print me the results of my post command, however, and got back Regine's error message ("'error': "undefined method `keys' for #<String:0xec3b9e5>:" etc)! The code seems to have run successfully -- nothing stops it from running/looping or throws up an error message.

Since I'm working in Python, I'm not sure how to fix what appears to be a Ruby error. I can work on adapting my code to ASnake, of course, but it would be nice to keep this one, since most of the work has already been done.

Best,
Elizabeth



--
Elizabeth M. Peters (she/her)
Senior Processing Archivist
Burns Library, Boston College

Regine I. Heberlein

unread,
Aug 18, 2025, 1:59:19 PMAug 18
to Elizabeth Peters, Lynn Moulton, Valerie Addonizio, Michelle Paquette, Archivesspac...@lyrasislists.org
Thanks for making that connection!! That definitely seems like it’s the same thing then. 

My completely unproven theory based on my experience--where the fix was removing the .to_json method--is that the json encoding is now handled elsewhere (I now send a hash when before I had to first make it into json). So my hunch is that by explicitly formatting the payload as json, we effectively json-ify it twice, which messes it up, hence the type error. That’s just me spitballing, though.

Valerie Addonizio

unread,
Aug 18, 2025, 2:19:23 PMAug 18
to Regine I. Heberlein, Elizabeth Peters, Lynn Moulton, Michelle Paquette, Archivesspac...@lyrasislists.org

I agree Regine, that it seems like the issue is passing an already-serialized JSON string into the json= (based on my example in Python).

 

Elizabeth, are you using json.dumps anywhere above this? Can you check the type of your payload to make sure it’s a dict or list and not a string?

Elizabeth Peters

unread,
Aug 18, 2025, 2:34:24 PMAug 18
to Valerie Addonizio, Regine I. Heberlein, Lynn Moulton, Michelle Paquette, Archivesspac...@lyrasislists.org
Aha, yes! I did have a json.dumps above this. I've taken it out, and now I still have errors, but at least they're unrelated to this and are more easily understandable/fixable.

Thanks,
Elizabeth

Brian Harrington

unread,
Aug 18, 2025, 3:17:53 PMAug 18
to Regine I. Heberlein, Archivesspac...@lyrasislists.org

Hi Regine,

 

In your case, I think the issue is probably related to this change in the Ruby archivesspace-client gem.  https://github.com/lyrasis/archivesspace-client/pull/22  That would explain why it fails on both 3.51 and 4.1, while the Python users seem to have no problem with 3.51.

 

I hope this helps.

 

Brian

 

From: "'Regine I. Heberlein' via Archivesspace_Users_Group" <Archivesspac...@lyrasislists.org>


Reply-To: "Regine I. Heberlein" <hebe...@princeton.edu>
Date: Monday, August 18, 2025 at 1:59 PM
To: Elizabeth Peters <pet...@bc.edu>

Regine I. Heberlein

unread,
Aug 18, 2025, 3:19:18 PMAug 18
to Brian Harrington, Archivesspac...@lyrasislists.org
Thanks Brian! I was looking at the client as my top suspect as well, this confirms it!
Reply all
Reply to author
Forward
0 new messages