How to Assert values while doing POST or PUT .They dont have any values in response body other than "SUCCESS"

How to Assert while doing POST or PUT .They dont have any response body .
Also if some one could explain how to assert against MongoDB values

Hey @orbital-module-pilo1

Welcome to the community! :wave:

It’s going to be really tricky for anyone to provide an answer, given the details in your question. :cry:

Could you take a look through this thread How to Best Ask Questions on Community to Get the Answers You Need and edit your question to provide more information and context, please.

2 Likes

Hi Danny ,

Thank you for the feedback .What I am really looking is how to assert POSTed value to MongoDB
All most all ,assert happens against the Response Body .If the API call does not yield any response body , my understanding is ,only solution is to connect to DB and see if the POST was successful .I might be wrong .I am new to API test using POSTMAN , so any help would be appreciated .

Example POST
Body :
{

“GroupName”: “{{GroupName}}”,
“Description”: “Test Group”
}

**Environment Variable **
GroupName

pre script:
var random=Math.random().toString(36).substring(2);

var GroupName=“madhu”+random+“group”;

pm.environment.set(“GroupName”,GroupName);

See if there is an endpoint to retrieve those data , if so first post it and validate status code and then do a get to the end point to get new values and assert that

1 Like

Hi @orbital-module-pilo1, You can also do assertions against the Request too, but I’m not sure how much value that will have for you.

If you wrote a test that asserts that GroupName property is in the request, it would always pass.
Look at pm.request.body object to access the request data. This is something I’ve used recently myself.

If you are using mongo atlas, then they have a product called mongo stitch which allows you to create a rest endpoint to check data has actually reached the database. Which would probably be more valuable to you.

Hi cruxto ,

I found solution in using pm.sendRequest in the test and doing validation against the response.json().That solved the no response body issue.
Yes, iam using mongo atlas.Thank you for the info abt mongo stitch i will explore on that .

1 Like