- CheckMates
- :
- Products
- :
- Developers
- :
- API / CLI Discussion
- :
- Re: R80.10 API verify-policy Postman response
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Are you a member of CheckMates?
×- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
R80.10 API verify-policy Postman response
I am trying to pass the task-id response value from a verify-policy request in Postman as an environment variable. However, it appears that the output of "task-id" is not a valid json reference? Based on my testing it appears to be because of the dash "-" in the name "task-id". Does anyone know of another why to retrieve this value?
Here is my request:
I perform a verify-policy POST and get the following response:
{
"task-id" : "01234567-89ab-cdef-9966-b355dd0c80f1"
}
That request also has a test script to take the value of "task-id" and put it in my environment as variable "tk".
var jsonData = JSON.parse(responseBody);
//use task as variable
postman.setEnvironmentVariable("tk", jsonData.task-id);
But executing this results in error, and the output from the Postman console indicates it is not defined, despite it shown in the response body.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In Javascript you cannot call a field from json with a hyphen in it the traditional way.
You have to do jsonObj['task-id']
javascript - Unable to access JSON property with "-" dash - Stack Overflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In Javascript you cannot call a field from json with a hyphen in it the traditional way.
You have to do jsonObj['task-id']
javascript - Unable to access JSON property with "-" dash - Stack Overflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks! That works!
My updated test script:
var jsonData = JSON.parse(responseBody);
//use task as variable
postman.setEnvironmentVariable("tk", jsonData['task-id']);