Passing JSON body using variable doesn't work


I have a PUT request created and I need to pass JSON body to it. Use case is to update the JSON body runtime and then passing it to PUT request.

Here is my API request. I have added a variable jsonBody and same I am using in HTTPBody as shown below.

Here is the script I have -

String jsonContent = '{"name":"John", "age":30, "car":null}'
Map<String, String> prop = new HashMap<String, String>()
prop.put('jsonBody', jsonContent)  
RequestObject requestObj = ((findTestObject('UpdateNoticeContent', prop)) as RequestObject)
ResponseObject respObj = ((WS.sendRequestAndVerify (requestObj)) as ResponseObject)
WS.verifyResponseStatusCode(respObj, 200)

Above script returns 500 error -

“status” : 500
Server error
Something went wrong
Please try again.

If I pass the jsonbody directly into the request like this, then it works fine. Can someone help to resolve this error?

Chandresh Parmar

I tried to reproduce your test case script and test object. It ran fine. I find no problem there.

Not enough diagnostics how your server behaved. You should check the server-side log to find the reason why the server responded with HTTP status 500.