AssertionError: expected ' ' to deeply equal




@sseenivasan89 Please have a look!

Waiting for your response @sseenivasan89 Sir

the response body comes as empty

What to do next @sseenivasan89 Sir?

investigate why the response is empty

Correct, reason i did is to ensure that ā€“ this error shouldnā€™t come expected undefined to deeply equal 10080 and as you mentioned ā€“ pm.expect(multiAcctNum).to.eql(10080); i tried it same error so kindly help me how to fix this error. thank in advance sir.

Sir you are correct. But,How to investigate? I am a beginner @sseenivasan89 Sir.

talk to your developer and check why no response is coming
what is the status code you are getting ?

@sseenivasan89 Sir I am doing it from a YouTube channel. You must have heard of Pavan Kumar Sir. Response code coming is 200 i.e. OK.
Please tell how to proceed.

@payload-observer-938

The response is showing a blank array. Nothing else.

Therefore it looks like there is something wrong with the request.

The API is showing a 200 code as technically I guess a blank array is valid JSON.

We will know nothing about that API, so this will be something for the trainer\supplier.

@ppoorna

Similar to the advice given to others. You need to post an example response and the corresponding tests tab.

If its coming back undefined, then you are not targeting the element correctly in the response.

Thanks @michaelderekjones Sir
Just wanted to know how you mastered Postman? I mean how I as a beginner should i approach and proceed.

@payload-observer-938

Iā€™m still learning Postman.

However, I have a background in technical support and testing in particular.

As a beginner, I would recommend starting with the Learning Center.

Postman Galaxy Training | Postman API Network

Run through the ā€œAPIs 101 Trainingā€, then the ā€œTesting and Automation Trainingā€ course.

You need to use the console log for troubleshooting. (This is covered in the training).

Postman uses JavaScript under the hood, so having a basic understanding of JavaScript will be advantageous. The WC3 Schools is a good place to start. In particular, the use of JavaScript objects and arrays.

Finally, you need to have a decent understanding of REST which is a standard that a lot of APIā€™s are developed to. This will include learning and understanding JSON.

When you parse the response using pm.response.json(), it converts the JSON to a JavaScript object. Hence you need to learn both when you are trying to target elements.

JSON can be complex, which can return JavaScript objects within objects, within arrays. So you need to learn what you are looking at and how to target the elements.

You should also look into Soap and XML which is an older but still widely used method.

Hi All - can you please help me below issue , i am getting below error while validating response body

code-
pm.test(ā€œjson data validationā€,() =>{
var jsonData = pm.response.json();
pm.expect(jsonData.first_name).to.eql(ā€œJanetā€);
});

error
ā€œjson data validation | AssertionError: expected undefined to deeply equal 'Janetā€

@dkrock

I would recommend posting this as its own question, rather than tagging it on the end of an already answered thread (which is probably why no-one has answered).

You havenā€™t posted an example response, so I canā€™t tell you exactly what you need to put, but the issues is related to ā€˜jsonData.first_nameā€™ being undefined, so this is not targeting that element correctly and is what you need to check.

@dkrock Welcome to the community!!

When the JSON parsing couldnā€™t locate the element it will throw this ā€œundefinedā€ error. Please check if the xpath is right. You can use https://jsonpathfinder.com/

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.