Hi,
I am trying to ready values from the BODY and a json request (no the response) and then set it in a variable. I can successfully do it the response body but not the request body.
Its a post request
Body:
{
"PolicyDN": "\\VED\\Policy\\Demo\\APIs\\Certificates",
"ObjectName": "api-example.se.venafi.com",
"Subject": "api-example.se.venafi.com",
"SubjectAltNames": [
{
"TypeName": "DNS",
"Name": "venafisan-example.se.venafi.com"
},
{
"TypeName": "DNS",
"Name": "venafisan-example2.se.venafi.com"
}
]
}
Tests Tab
tests[""] = !(responseBody.has(“Error”));
var data = JSON.parse(responseBody);
postman.setEnvironmentVariable(“Cert_DN”, data.CertificateDN.replace(/\/g,"\$&"));
postman.setEnvironmentVariable(“GUID”, data.Guid);
Tyring to add something for the "Request Value in the request body. Something like this (This does not work)
var mydata = JSON.parse(requestBody);
postman.setEnvironmentVariable(“Subject”, mydata.Subject);
I am sure the solution/syntax is easy. Just not sure how to do it.
Any help would be greatly appreciated.