Added a script ❌

Add a test script that gets the value of the rand property in the response JSON and sets it as the value of a variable (at collection or environment scope) named responseData. Hint: You’ll need to Send the request twice after adding your code because it won’t save the value until after the response is received the first time.

I am getting an issue in this. This is my code, where am I probably going wrong?
pm.test(‘Stats include all fields’, function () {

var jsonData = pm.response.json().data;

pm.environment.set(“responseData”, jsonData.rand);

});

Hey @telecoms-technologi1

I’m guessing this is part of the student expert training and is the skill check request.

You have .data on the end of the jsonData variable and I don’t believe that the rand property is a nested one.

ITs done, actually I did not set the environment to the new one I created. Thanks a lot.

Hi @telecoms-technologi1 @dannydainton can you help here its saying rand is undefined

@RavneetK94 See this response and you will get it.

2 Likes

hey issue resolved thanks :slight_smile: