You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Munendra S N (JIRA)" <ji...@apache.org> on 2019/07/20 09:10: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 ]

Munendra S N updated SOLR-11760:
--------------------------------
    Issue Type: New Feature  (was: Bug)

> 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: New Feature
>          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 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.
> {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
(v7.6.14#76016)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org