unable to read the postman data properly using scripted rest api
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 11:02 PM - edited 03-14-2024 11:18 PM
below is the data i have in postman
{
"info": [
{
"minimumvalue": "1",
"desiredValue": "2",
"maximumValue": "3",
},
{
"minimumvalue": "4",
"desiredNodes": "5",
"maximumNodes": "6",
}
]
} for getting these values i written the script in scripted rest api but it's not working
var user_min3 = details.info[1].minimumvalue;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 11:54 PM
Hi @Rama26
var details = request.body;
var jobj= JSON.stringify(details);
var jsonObject = JSON.parse(jobj);
var user_min1 = jsonObject.info[0].minimumvalue;
var user_min2 = jsonObject.info[1].minimumvalue;
gs.info(user_min1);
gs.info(user_min2);
Thanks
dgarad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2024 12:17 AM
or this also received same error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2024 12:22 AM
I tried the BG script it's working fine
var jsondata={
"info": [
{
"minimumvalue": "1",
"desiredValue": "2",
"maximumValue": "3",
},
{
"minimumvalue": "4",
"desiredNodes": "5",
"maximumNodes": "6",
}
]
};
var jobj= JSON.stringify(jsondata);
var jsonObject = JSON.parse(jobj);
var user_min1 = jsonObject.info[0].minimumvalue;
var user_min2 = jsonObject.info[1].minimumvalue;
gs.info(user_min1);
gs.info(user_min2);
Thanks
dgarad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2024 03:07 AM
Same i tried with Scripted rest api it's not working.