OmekaAPIClient for python

Dear Community,

I’m working (the url is my test repository with open api) with python client api using:

#Tools for working with data in an instance of Omeka S
from omeka_s_tools.api import OmekaAPIClient

omeka1 = OmekaAPIClient('https://ygx.sop.mybluehost.me/omekas/api')

data = omeka1.get_resources('items')
data['total_results']

I have this error when executing the above code:

Any idea what could be wrong?

Omeka S doesn’t produce a 406 “Not Acceptable” error.

It looks like this is coming from your host, potentially blocking requests with the default Python “requests” library user-agent.

1 Like

Thanks for the answer, now how can I fix this in the client api? omeka_s_tools

Would I have to add a header in the api.ipynb functions that have the get and post method?

What would be the functions (to modify) or is there a direct way to do it with the omeka s tools library?

You might want to check in with @wragge, the author of the library you’re using.

My guess from a quick look is that you probably are best off setting the User-Agent header in the __init__ method: self.s there is a Session object that you can set a header on and have it used for all the requests.

Thanks @jflatnes , I put in “Session()” the headers and it ran successfully.

Since posting that, I’ve had a better thought: you can just get at that Session object from the OmekaAPIClient that you create in your own script. You can, using your script for example, set a dict of your desired headers to omeka1.s.headers.

1 Like

This topic was automatically closed 360 days after the last reply. New replies are no longer allowed.