简体   繁体   中英

WSO2 EI - how to handle malformed JSON requests in API

I have created an API in WSO2 EI. API is expecting the requests to be send as JSON. If it is a malformed JSON which is sent, then I should be able to receive it and make appropriate changes to make it a proper JSON.

Any help is much appreciated.

As we are using json-eval($.) to get the message to property, it is not working for me. What else i could try instead of json-eval to get the message as string.

WSO2 EI has the property force.json.message.validation , which can be used to validate incoming JSON payload. Please refer doc to configure this property in 'passthru-http.properties' file.

Once the property is configured, if there is a malformed JSON payload in the request, the mediation flow will be directed to the fault/error sequence. So, you can define the mediation logic to make appropriate changes to the malformed content within the fault sequence of your API.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM