Hi. I made a post request to my end points and got a 201 status code which is suppose to happen but I got this message from redash below:

my query are as below:

method: post
url: "https://example.com/api/stats/tickets-per-tag"
headers:
    Authorization: hidden
    content-type: application/json
data: 
   '{"filters":{"period":{"start_datetime":"2020-10-15T10:10:04+00:00","end_datetime":"2020-10-17T10:10:04+00:00"}}}'

I tired with an API tester and is working and received below response with a 201 status code

{"meta": {"end_datetime": "2020-10-17T10:10:04+00:00", "previous_start_datetime": "2020-10-13T10:10:04+00:00", "previous_end_datetime": "2020-10-15T10:10:04+00:00", "start_datetime": "2020-10-15T10:10:04+00:00"}, "data": {"label": "Tickets created per tag", "data": {"axes": {"x": [{"name": "Tag", "type": "string"}, {"name": "Total", "type": "number"}, {"name": "Percentage", "type": "percent"}, {"name": "Delta", "type": "delta"}]}, "lines": [[{"type": "string", "value": "Untagged"}, {"type": "number", "value": 1}, {"type": "percent", "value": 20}, {"type": "delta", "value": 100}], [{"type": "string", "value": "HK_Online"}, {"type": "number", "value": 4}, {"type": "percent", "value": 80}, {"type": "delta", "value": 100}], [{"type": "string", "value": "HK_Order/Change address"}, {"type": "number", "value": 1}, {"type": "percent", "value": 20}, {"type": "delta", "value": 100}]]}}}

Looks to me like the JSON query runner inherits this behaviour from the BaseHTTPQueryRunner - a 200 status code is the expected response for success, 4xx and 5xx status codes are returned as errors and anything else (e.g. 201 code above) generates the above “unexpected status code” message.

https://github.com/getredash/redash/blob/1b8ff8e810aaa81c8aa8f28aef9e1ca3632b8521/redash/query_runner/init.py

I’m not an expert on HTTP responses but 201 (“Created”) seems like it should be handled as a success, not an unexpected code.

1 Like

Should I submit a bug report on github? I wonder how can I get this fix

I think that’s probably a good idea