cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Escape characters added when submitting synthetic HTTP POST call with json request body

Harvey
Newcomer

I've created a HTTP POST synthetic call to an application that uses json payloads for the requests. When entering the request body with valid json, I can see in the subsequent calls that Dynatrace is adding in escape characters for the double quotes in the json, i.e. '\"'. The application is reading this rejects the request as the json is not well formed. I've separately testing the json request payload successfully.

 

Looking at the request body in script mode it looks like the script is itself json with the requestBody field attempting to add the request payload using the escaped double quotes. Is there a means of using a json request payload with a HTTP synthetic call without corrupting the json? Or possibly a means of adding the json payload into the prerequest script and calling it as a json object in the requestBody to avoid the escape characters?

3 REPLIES 3

HannahM
Dynatrace Leader
Dynatrace Leader

You can manipulate and set the request body in pre-request scripts using 

request.setBody(requestBody)

using https://docs.dynatrace.com/docs/shortlink/http-monitor-pre-post-script#pre-execution

Synthetic SME and community advocate.

Thanks for getting back to me. I've tried adding the below to the pre request script.

 

var json = '{jsonArray}';
request.setBody(json);

 

Dynatrace is still adding in the escape characters to the requestBody json though which is breaking it when it reaches the application due to the backslashes.

 

Is there any other means of submitting requestBody json or disabling the backslashes that are being added?

HannahM
Dynatrace Leader
Dynatrace Leader

Can you open an in-product chat to look at this? 

Synthetic SME and community advocate.

Featured Posts