Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

118
Views
postman read property in json response which name is saved in array

I am trying to check values of certain properties in json response in postman.

pm.expect(jsonData.property).not.equal(null);

The thing is, that I need to check multiple properties which names I have stored in an array.

var jsonData = pm.response.json();
var keys = ["id", "phoneNumber", "passwordHash"];

pm.test("All values have valid value", function(){
   for(var a = 0; a < keys.length; a++){
      pm.expect(jsonData.keys[a]).not.equal(null);
   };
});

But I am getting this error:

All values have valid type | TypeError: Cannot read property '0' of undefined

Can someone explain me, what am I doing wrong please? Thanks for any advice.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You cann't use (.) dot to get a value of a unknown key, use [] bracket instead. Try this:

pm.expect(jsonData[keys[a]]).not.equal(null);

One subtle thing, in my opinion, use i (mean index) is better than a.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!