Details
-
New Feature
-
Status: Resolved
-
Minor
-
Resolution: Duplicate
-
6.6
-
None
-
None
Description
We generally request JSON from SOLR, via HTTP with wt=json (without using a client impl).
In case of fundamental errors, however, no JSON is returned but XML (either because wt=json is not transmitted correctly or the request handler that understands this parameter is not executed). It would be nice if in this case the `Accept:application/json` header could be honored.
$ http http://localhost:8983/solr/offers_gb/select q==*:* wt=json rows=1 Accept:"application/json" -v POST /solr/offers_gb/select?q=%2A%3A%2A HTTP/1.1 Accept: application/json Accept-Encoding: gzip, deflate Connection: keep-alive Content-Length: 27 Content-Type: application/json Host: localhost:8983 User-Agent: HTTPie/0.9.4 { "rows": "1", "wt": "json" } HTTP/1.1 400 Bad Request Content-Length: 525 Content-Type: application/xml; charset=UTF-8 <?xml version="1.0" encoding="UTF-8"?> <response> <lst name="responseHeader"><int name="status">400</int><int name="QTime">0</int><lst name="params"><str name="q">*:*</str><str name="json">{"wt": "json", "rows": "1"}</str></lst></lst><lst name="error"><lst name="metadata"><str name="error-class">org.apache.solr.common.SolrException</str><str name="root-error-class">org.apache.solr.common.SolrException</str></lst><str name="msg">Unknown top-level key in JSON request : wt</str><int name="code">400</int></lst> </response>
As opposed to:
$ http http://localhost:8983/solr/offers_gb/select q==bla:* wt==json rows==1 Accept:"application/json" -v GET /solr/offers_gb/select?q=bla%3A%2A&wt=json&rows=1 HTTP/1.1 Accept: application/json Accept-Encoding: gzip, deflate Connection: keep-alive Host: localhost:8983 User-Agent: HTTPie/0.9.4 HTTP/1.1 400 Bad Request Cache-Control: no-cache, no-store Content-Length: 282 Content-Type: application/json; charset=UTF-8 ETag: "1605105208b" Expires: Sat, 01 Jan 2000 01:00:00 GMT Last-Modified: Wed, 13 Dec 2017 17:56:18 GMT Pragma: no-cache { "error": { "code": 400, "metadata": [ "error-class", "org.apache.solr.common.SolrException", "root-error-class", "org.apache.solr.common.SolrException" ], "msg": "undefined field bla" }, "responseHeader": { "QTime": 0, "params": { "q": "bla:*", "rows": "1", "wt": "json" }, "status": 400, "zkConnected": true } }
Attachments
Issue Links
- duplicates
-
SOLR-10998 Support "Accept" request header as alternative to "wt" parameter
- Open
- is related to
-
SOLR-11266 V2 API returning wrong content-type
- Closed