Chai/test syntax help

Can anyone tell me why this JSON is throwing this property validation error:

Test object property | AssertionError: expected ‘{“LastEditDate”:“2021-08-02T12:08:29.0000000”,“ProjClass”:3,“ProjectStateID”:0,“ID”:53,“CurrentUserID”:6,“CreatedBy”:6,“SchemaName”:2}’ to have property ‘ID’


It’s a simple:


and you can see the body returned in that call.

Thanks for the help.

Hi @dmgprecise

Welcome to the Community :tada:

Could you please share the response that is generated for the request you sent to have a clear idea on why the error is generated?

Sorry, I’m not trying to be difficult but as I understand it Postman is taking the JSON I posted and saying “no such property exists in this JSON”. Which it does. And that body I sent should be the only thing being checked in that validation. So what would the rest of the Response have to do with anything?

(this isn’t the only “no property” problem I have in Postman/Chai, this is just the one I picked to show you, that exact assert never seems to work at all, others do depending . . . but this should be a simple enough example to crack into)

Answer was endpoint was returning a string. Postman wouldn’t recognize that as JSON. Change the return type to IActionResult (C#) and wrap the same JSON in an OK() response and it all validates.

Is the issue solved ?

Other than Postman not recognizing a string of JSON as JSON :wink:

But otherwise yes when using a compatible return type, Postman will now recognize the body and properties


it works as expected , i am not sure whats jsonData contains , try


pm.response.json() gets the json response body