the response body comes as empty
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.
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.
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.
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.
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ā
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.