Api consume request body error

Hi, i've configured a consume POST rest api and in the body of request i've a field with a string that is a json regex string conversion like this: {\"sessionInfo\":{\"Id\":\" ....... in the service center i see that when run tha api the string change in:  dataInterceptorString":"{\\\"sessionInfo\\\":{\\\"Id\\\":\\\ ....... and the api return me an error. Why there is this change?

Andrea Sartori wrote:

Hi, i've configured a consume POST rest api and in the body of request i've a field with a string that is a json regex string conversion like this: {\"sessionInfo\":{\"Id\":\" ....... in the service center i see that when run tha api the string change in:  dataInterceptorString":"{\\\"sessionInfo\\\":{\\\"Id\\\":\\\ ....... and the api return me an error. Why there is this change?

Hi 

Please clarify the situation. Did you use the regex in the JSON to get the result? please let me know and clarify it. If u use regex, it may be due to regex it is making extra // in the JSON.


Andrea Sartori wrote:

Hi, i've configured a consume POST rest api and in the body of request i've a field with a string that is a json regex string conversion like this: {\"sessionInfo\":{\"Id\":\" ....... in the service center i see that when run tha api the string change in:  dataInterceptorString":"{\\\"sessionInfo\\\":{\\\"Id\\\":\\\ ....... and the api return me an error. Why there is this change?

Hi Andrea,

You can encode the request data before passing it to the API and decode it after receiving. Also u can convert the data in binary and pass it into the request and receive it in a binary variable.In that way your data will be secure and easy to access.

 


Sudip Dey wrote: no i pass this json in the payload request
{
"requestData":
{
"action": "checkoutCart",
"dataInterceptorString": "{{cartString}}"
}
}

"{{cartString}}" is a json converted in a string and with some regex rule but is a string like this:
{\"sessionInfo\":{\"Id\":\"..... , the problem is that the request body is a json and the json encoder change "\"  with the escape in the string with "\\\" for example dataInterceptorString":"{\\\"sessionInfo\\\":{\\\"Id\\\":\\\ .......

Andrea Sartori wrote:

Hi, i've configured a consume POST rest api and in the body of request i've a field with a string that is a json regex string conversion like this: {\"sessionInfo\":{\"Id\":\" ....... in the service center i see that when run tha api the string change in:  dataInterceptorString":"{\\\"sessionInfo\\\":{\\\"Id\\\":\\\ ....... and the api return me an error. Why there is this change?

Hi 

Please clarify the situation. Did you use the regex in the JSON to get the result? please let me know and clarify it. If u use regex, it may be due to regex it is making extra // in the JSON.




Atul sharma wrote: is no possible pass binary data in the request because the api want "application/json" in content type.

Andrea Sartori wrote:

Hi, i've configured a consume POST rest api and in the body of request i've a field with a string that is a json regex string conversion like this: {\"sessionInfo\":{\"Id\":\" ....... in the service center i see that when run tha api the string change in:  dataInterceptorString":"{\\\"sessionInfo\\\":{\\\"Id\\\":\\\ ....... and the api return me an error. Why there is this change?

Hi Andrea,

You can encode the request data before passing it to the API and decode it after receiving. Also u can convert the data in binary and pass it into the request and receive it in a binary variable.In that way your data will be secure and easy to access.

 




Ok i solved the problem, i remove the regex conversion of the text in the dataInterceptorString field