Does postman mock server can return status code 449

792 Views Asked by At

I try to use Postman to mock server functionality to mock an API call that will return status code 449. For some reason, the good response body is return, but the status code stays at 200.

I can change the example to return 404, 422, 451, and others, but as soon as I set 449 for the status code, it returns 200.

Is there a way to make the mock server return status code 449?

Edit: I add a collection and environment that reproduce the problems https://github.com/freddycoder/PostmanStatusCode

1

There are 1 best solutions below

0
PDHide On

449 is not an official status code.

https://dynomapper.com/blog/254-the-6-types-of-http-status-codes-explained#:~:text=A%20449%20error%20appears%20when,order%20to%20fulfill%20a%20request.

The below site shows the officially assigned status codes. it seems like as of now unassigned ones are not supported in postman expect apache status code 509. Maybe mock servers use apache and 449, 450 etc are windows specific status codes.

https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

You can test the specific usecase with the x-mock-response-code request header

enter image description here

On setting this header postman returns response only if the example of mock server has status code set as 449.

enter image description here

else you will get 404 mockRequestNotFoundError .

so in your test you can set pm.response.code = 449 if response code is 200;

To do this in pre reqeust set :

pm.response.code===200?pm.response.code=449:null
pm.response.code===449?pm.response.status="Retry With":null

console.log(pm.response.code,pm.response.status)