03 Jul 2024 04:07 PM
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?
Solved! Go to Solution.
04 Jul 2024 09:00 AM
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
04 Jul 2024 10:20 AM
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?
04 Jul 2024 02:28 PM
Can you open an in-product chat to look at this?