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 a sample response body, where I am able to set presignedURL but the orderId value is not working in the postscript.

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

When I tried the 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 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 anyone know any suggestions?

Regards, Venkat

 

0 REPLIES 0