On 5/18/2017 1:52 AM, gigo314 wrote:
> Thanks, that was my assumption as well that all parameters should are
> supported by both GET and POST. However, when using JSON API I keep getting
> 400 error code:
>
> /Request/:
> {"query":"*","cursorMark":"*","sort":"id asc"}
>
> /Response/:
> {"responseHeader":{"status":400,"QTime":0,"params":{"fl":"id","json":"{\"query\":\"*\",\"cursorMark\":\"*\",\"sort\":\"id
> asc\"}","rows":"1","wt":"json"}},"error":{"metadata":["error-class","org.apache.solr.common.SolrException","root-error-class","org.apache.solr.common.SolrException"],"msg":"*Unknown
> top-level key in JSON request : cursorMark*","code":400}}
You still haven't told us how you are sending requests to Solr, whether
it's being constructed manually and sent with an HTTP module in a
programming language, with curl, or whether you are using a Solr
library, and if so, what language it's for.

I have no idea how to use the JSON API for queries.  I also have no idea
what parameters it supports.  Based on the documentation page, it
doesn't use standard parameters -- the example has "query" and "filter"
where the standard URL parameters for these are "q" and "fq" ... so it
is entirely possible that it cannot support arbitrary parameters like
cursorMark.  The error message says that cursorMark is an unknown top
level JSON key, which supports this idea.

Speaking generally, and not language specific:

You would just put the parameters in the request body, like they would
appear on the URL.  I think to use this, the Content-Type header would
be "|application/x-www-form-urlencoded|".

I *think* that each parameter (not counting the & characters between
them) should be run through a URL encoding routine before being added to
the body.  It's possible that whatever library you're using would do
this automatically, but unless you know for sure, don't assume that.

This might be the sort of thing you need to send in the body:

q%3d*%3a*&fl%3did&cursorMark%3dAoEpVkRCREIxQTE2

In that URL encoded string, an equal sign is %3d and a colon is %3a, so
the decoded string that the servlet container running Solr would see is
this:

q=*:*&fl=id&cursorMark=AoEpVkRCREIxQTE2

When you put URL parameters into a browser, the browser automatically
does the URL encoding for you, and doesn't ever show you the encoded
version.

Thanks,
Shawn

Reply via email to