How to create global of int id using code in Tests?

Hey @sero.barseghyan

Within your response body, the photos property type is an array, which contains an object. The reference to the id value in your code is nearly correct but you need to specify which object in the array you want.

You would do this by passing an index number, arrays are zero indexed so the first item in the array would be 0.

Your code would need to look like this:

let jsonData_collection_Photoid = pm.response.json();
pm.globals.set("photo collection id", jsonData_collection_Photoid.photos[0].id);

I’ve written more about accessing JSON response data in this post: