Will throw others HTTP responses than 200 OK or 304 an exception?

2
I read in a old documentation (< Mendix 8)  that "This method returns a RequestResult object if the service responds with HTTP response 200 OK or 304 Not Modified. In all other cases an exception will be thrown."   https://github.com/mendix/RestServices#consuming-rest-services https://marketplace.mendix.com/link/component/997   How it is in Mendix 9? Can I use 204 (No content) without catch a exception? Is there some documentation about that? Thanks, merci, Pascal
asked
3 answers
1

Hi Pascal, 

 

In Mendix 9 you have a Call Rest action for consumption 

https://docs.mendix.com/refguide/call-rest-action/#latesthttpresponse

https://docs.mendix.com/refguide/import-mapping-action/

 

“If HTTP response status code is not successful (for example, [4xx] or [5xx]), the flow will continue in an error handler.

You should always add an error handler for a call REST service action.”

 

You will get a error, however, if you try to directly apply the import map with a response without content..

So.. you can just store the “Http Response” into a Variable and implement your validations for anything response code < 400. And then apply a Import With Mapping with appropriate map (erro response or data response)

 

Best regards

 

answered
0

Everything other than 20x http code will result in an exception. You have to handle other HTTP codes by yourself in the errorhandling

 

easy testing with this website: https://httpstat.us/ 

answered
0

In deed, no error with 201,202,204,299.


In vcode I use

GET https://httpstat.us/204 HTTP/1.1

Content-Type: application/json

accept: application/json


204  gives no json back!

answered