I'm trying to set a collection variable, but postman do not set it

I do at the end of the tests

pm.collectionVariables.set(“exampleVariable”, jsonData.id);

But postman creates a variable without any value

i have a lot of variables in the collections, but i never had any problem with it

Hi there!

Can you post an example of what your jsonData object looks like?

Perhaps id is undefined :thinking:

Check out this collection to see how I did it :smile:

1 Like

const jsonData = pm.response.json();

response:
{
“id”:1,
“name”:“Juan”
}

The problem is that sometimes it works but sometimes it dont work

Even if i do pm.collectionVariables.set(“test”,“test”);

postman create the variable test but its an empty variable

imagen

Sorry you’re still having trouble with this. Definitely not the kind of experience we want our users to have!

There have been some issues with Postman Sync this week which could be the culprit given that it seems to work inconsistently. You can check for service interruptions on the Postman Status page here.

The other possibility would be your internet connection. Are you perhaps behind a proxy or on an unstable connection?

If this continues to occur, I would recommend opening a support ticket here.

2 Likes

Hi @spacecraft-astronau2,

Could you please save the collection and retry closing all the tabs? May be some conflict issue. Also I believe you are providing the above snippet under “Tests” section.

Also regarding the response, it the same schema every time. No array’s?

1 Like