Rest API call - 422 error

0
Hello All, we are trying to send raw JSON data with an API we are trying to call, but we keep on getting 422 error. can anyone please help how we can remediate the same. Thanks a lot in advance!   An error has occurred while handling the request. [User 'ABC' with session id '717ce939-XXXX-XXXX-XXXX-XXXXXXXX94ac' and roles 'Administrator']   --------   com.mendix.webui.WebUIException: Exception while executing runtime operation  at com.mendix.webui.actions.client.RuntimeOperationAction.apply(RuntimeOperationAction.scala:72)   Caused by: com.mendix.modules.microflowengine.MicroflowException: Error calling REST service  at MyFirstModule.ACT_GenerateDocument (CallRest : 'Call REST (POST)')   Advanced stacktrace:  at com.mendix.integration.actions.microflow.RestCallAction.execute(RestCallAction.scala:79)   Caused by: com.mendix.modules.microflowengine.MicroflowException: 422: Unprocessable Entity  at MyFirstModule.ACT_GenerateDocument (CallRest : 'Call REST (POST)')   Advanced stacktrace:  at com.mendix.integration.actions.microflow.RestCallAction.checkStatusCode(RestCallAction.scala:117)     Warm Regards  
asked
1 answers
0

Hi Vineeth,

A HTTP Status Code 422 is not very common; what type of server do you call (i.e. is it custom-made or off the shelf)?

Sometimes it's used as validation feedback, i.e. it's the correct format (e.g. a String), but not an allowed value.

The 422 (Unprocessable Entity) status code means the server understands the content type of the request entity (hence a 415(Unsupported Media Type) status code is inappropriate), and the syntax of the request entity is correct (thus a 400 (Bad Request) status code is inappropriate) but was unable to process the contained instructions.

My approach would be to inspect the response body, as I would expect instructions from the server which field cannot be parsed. You could set the Log Level of REST Consume to Trace or add additional logging in the error handling of the Call REST activity. Could you share both your request and the response? This might give a hint where the error is.

Kind regards,

Johan

answered