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

Unable to set Json value in http monitor | Postscript execution

VenkataSainath
Contributor

I have below sample response body , where I am able to set presignedURL but orderId value is not working in the post script.

{
"presignedUrl": "https://abcd.com",
"status": {
"orderid": "CCIR#6bad551aa2724d60b8bf249c5dab8a7f",
"error_code": "",
"message": "",
"status": "SUCCESS"
}
}

Which i tried below postscript, it was giving syntax error.
if (response.getStatusCode() != 200) {
api.fail("HTTP error: " + response.getStatusCode());
}
var responseBody = response.getResponseBody();
var jsonData = JSON.parse(responseBody);
api.info(jsonData.presignedUrl);
api.setValue("oderid-1", jsonData.status.orderid);
api.info(jsonData.status.orderid);
}
Another way i also i tried but still same error 
if (response.getStatusCode() != 200) {
api.fail("HTTP error: " + response.getStatusCode());
}
var responseBody = response.getResponseBody();
var jsonData = JSON.parse(responseBody);
api.info(jsonData.presignedUrl);
api.setValue("oderid-1", jsonData.status["orderid"]);
api.info(jsonData.status.["orderid"]);
}

Did any one know any suggestion.


Regards,

Venkat

 

0 REPLIES 0