You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Chantal Ackermann (JIRA)" <ji...@apache.org> on 2017/12/13 17:59:00 UTC
[jira] [Updated] (SOLR-11760) Accept Header is not honored / Errors
returned in XML instead of JSON
[ https://issues.apache.org/jira/browse/SOLR-11760?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Chantal Ackermann updated SOLR-11760:
-------------------------------------
Summary: Accept Header is not honored / Errors returned in XML instead of JSON (was: Accept Header is not honored / Errors)
> Accept Header is not honored / Errors returned in XML instead of JSON
> ---------------------------------------------------------------------
>
> Key: SOLR-11760
> URL: https://issues.apache.org/jira/browse/SOLR-11760
> Project: Solr
> Issue Type: Bug
> Security Level: Public(Default Security Level. Issues are Public)
> Components: Response Writers
> Affects Versions: 6.6
> Reporter: Chantal Ackermann
> Priority: Minor
>
> We generally request JSON from SOLR, via HTTP with {{wt=json}} (without using a client impl).
> In certain error cases, however, no JSON is returned but XML, most likely because the request handler that understands the parameter {{wt=json}} is not even executed if the error is a fundamental one. It would be nice if in this case the `Accept:application/json` header could be honored.
> {code}
> $ 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>
> {code}
> As opposed to:
> {code}
> $ 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
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org