Hi. This is my response. There are Items and Photos. I need to create global from photos > id to have that photo id’s value as global to use in my next request.
{
"status": "success",
"id": 296320965219101,
"title": "New Private Collection.",
"desc": "This is my private collection",
"total": 1,
"public": false,
"user": {
"id": 29348278687687661,
"username": "jack.smith",
"name": "Jack Smith",
},
"items": [
{
"id": 2880058789753201,
"url": "https://picture.example.jpg",
"title": "#NeonLights",
"width": 1080,
"height": 1080,
"mature": false,
"public": true,
"likes_count": 0,
"views_count": 27,
"reposts_count": 0,
"comments_count": 0,
"sources": [],
"user_id": 989089889989,
"is_reposted": false
}
],
"photos": [
{
"id": 16127871367813,
"url": "https://picture.example.jpg",
"title": "#NeonLights",
"width": 1080,
"height": 1080,
"mature": false,
"public": true,
"likes_count": 0,
"views_count": 27,
"reposts_count": 0,
"comments_count": 0,
"sources": [],
"user_id": 287958404019101,
"is_reposted": false
}
],
"metadata": {}
}
I use this code in my pre-request to parse the id into string
pm.globals.set("photo collection id_parsed" , parseInt(pm.globals.get("photo collection id ")) )
And in Tests I use this code to create global for id from photos section.
let jsonData_collection_Photoid = pm.response.json();
pm.globals.set("photo collection id", jsonData_collection_Photoid.photos.id);
But I don’t get any saved global after sending the request, please recommend some solution