API and curl problem

21 views
Skip to first unread message

Peter Gilles

unread,
Dec 15, 2020, 11:52:19 AM12/15/20
to NoSketch Engine
Hi all,
I am trying to construct a curl call (for usage in R or Python) to query my corpus via bonito.

When using an URL API call like:


I will receive the desired JSON result.

However, when I try to do the same with curl, e.g.:

curl -F "corpname=korpus_new" -F "q=q[lemma="iech"]" -F "format=json"   "http://server.url/bonito/run.cgi/view"

I will receive an error:

{"request": {}, "api_version": "open-4.24.6", "error": "'NoneType' object has no attribute '__getitem__'"}

I am a bit lost here. I tried to build the call according to the information mentioned on https://www.sketchengine.eu/documentation/api-documentation/#toggle-id-5.

Thanks,
Peter

Ondřej Herman

unread,
Dec 15, 2020, 3:31:55 PM12/15/20
to Peter Gilles, NoSketch Engine
Dear Peter,

I'm not exactly sure what the root cause is, but as a quick fix -- if you specify corpname as an URL parameter (and escape the quotes), everything works fine:


Best,

Ondrej

--
You received this message because you are subscribed to the Google Groups "NoSketch Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to noske+un...@sketchengine.co.uk.
To view this discussion on the web visit https://groups.google.com/a/sketchengine.co.uk/d/msgid/noske/fb798a9c-f2d8-442b-861b-7f114b8fca12n%40sketchengine.co.uk.

Miloš Jakubíček

unread,
Dec 16, 2020, 3:51:11 AM12/16/20
to Ondřej Herman, Peter Gilles, NoSketch Engine
It's exactly that: corpname must be part of the URL, i.e. may not be POSTed (which is what curl -F does).

I will ask someone to look into that and either fix it or update the documentation.
As far as I remember the rationale was to ease per-corpus authentication (which can easily then be handled by a webserver like nginx or apache).

Best
Milos


Milos Jakubicek

CEO, Lexical Computing
Brno, CZ | Brighton UK


Peter Gilles

unread,
Dec 17, 2020, 5:47:57 AM12/17/20
to NoSketch Engine, Miloš Jakubíček, NoSketch Engine, ondrej...@sketchengine.co.uk
Thanks! It is working now. 
Peter

Reply all
Reply to author
Forward
0 new messages