# Chai/test syntax help

**URL:** <https://community.postman.com/t/chai-test-syntax-help/26379>\
**Category:** Help Hub\
**Created:** [August 3, 2021, 2:20am UTC](https://community.postman.com/t/chai-test-syntax-help/26379 "2021-08-03T02:20:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmgprecise](https://avatars.discourse-cdn.com/v4/letter/d/a88e4f/32.png) [@dmgprecise](https://community.postman.com/u/dmgprecise)\
**Post date:** [August 3, 2021, 2:20am UTC](https://community.postman.com/t/chai-test-syntax-help/26379/1 "2021-08-03T02:20:02Z")

</div>

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:

pm.expect(jsonData.json()).has.property(“ID”);

and you can see the body returned in that call.

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![jency.stella19](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/jency.stella19/32/16633_2.png) [@jency.stella19](https://community.postman.com/u/jency.stella19)\
**Post date:** [August 3, 2021, 3:13am UTC](https://community.postman.com/t/chai-test-syntax-help/26379/2 "2021-08-03T03:13:32Z")

</div>

Hi @dmgprecise

Welcome to the Community 🎉

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?

---

<div class="post-metadata">

**Author:** ![dmgprecise](https://avatars.discourse-cdn.com/v4/letter/d/a88e4f/32.png) [@dmgprecise](https://community.postman.com/u/dmgprecise)\
**Post date:** [August 3, 2021, 5:56pm UTC](https://community.postman.com/t/chai-test-syntax-help/26379/3 "2021-08-03T17:56:35Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![dmgprecise](https://avatars.discourse-cdn.com/v4/letter/d/a88e4f/32.png) [@dmgprecise](https://community.postman.com/u/dmgprecise)\
**Post date:** [August 4, 2021, 3:10am UTC](https://community.postman.com/t/chai-test-syntax-help/26379/4 "2021-08-04T03:10:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jency.stella19](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/jency.stella19/32/16633_2.png) [@jency.stella19](https://community.postman.com/u/jency.stella19)\
**Post date:** [August 4, 2021, 3:48am UTC](https://community.postman.com/t/chai-test-syntax-help/26379/5 "2021-08-04T03:48:49Z")

</div>

Is the issue solved ?

---

<div class="post-metadata">

**Author:** ![dmgprecise](https://avatars.discourse-cdn.com/v4/letter/d/a88e4f/32.png) [@dmgprecise](https://community.postman.com/u/dmgprecise)\
**Post date:** [August 4, 2021, 3:51pm UTC](https://community.postman.com/t/chai-test-syntax-help/26379/6 "2021-08-04T15:51:30Z")

</div>

Other than Postman not recognizing a string of JSON as JSON 😉

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

---

<div class="post-metadata">

**Author:** ![praveendvd](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/praveendvd/32/6796_2.png) [@praveendvd](https://community.postman.com/u/praveendvd)\
**Post date:** [August 4, 2021, 5:45pm UTC](https://community.postman.com/t/chai-test-syntax-help/26379/7 "2021-08-04T17:45:05Z")

</div>

> [@dmgprecise](#):
>
> has.property(“ID”);

```auto
pm.expect({"LastEditDate":"2021-08-02T12:08:29.0000000","ProjClass":3,"ProjectStateID":0,"ID":53,"CurrentUserID":6,"CreatedBy":6,"SchemaName":2}).has.property("ID")

```

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

```auto
pm.expect(pm.response.json()).has.property("ID")

```

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