# \#responseassertion

**URL:** https://community.postman.com/tag/responseassertion/110.md

[Latest](https://community.postman.com/latest.md) · [Categories](https://community.postman.com/categories.md) · [Tags](https://community.postman.com/tags.md)

---

## [Save responses to a file in our local machine](https://community.postman.com/t/save-responses-to-a-file-in-our-local-machine/13861)

<div class="topic-metadata">

**Author:** [@girirokr](https://community.postman.com/u/girirokr)\
**Replies:** 4\
**Last updated:** [November 25, 2024, 7:49am UTC](https://community.postman.com/t/save-responses-to-a-file-in-our-local-machine/13861 "2024-11-25T07:49:16Z")

</div>

Hi All, I need one solution to save all the json response to a file in my local machine when all the test assertion passed in the test-tab. Pls suggest me a solution to save the Response files locally with the same req…

---

## [Data Driven Testing - Assertion in CSV field](https://community.postman.com/t/data-driven-testing-assertion-in-csv-field/70994)

<div class="topic-metadata">

**Author:** [@vinodhayyavu57](https://community.postman.com/u/vinodhayyavu57)\
**Replies:** 0\
**Last updated:** [November 8, 2024, 11:35am UTC](https://community.postman.com/t/data-driven-testing-assertion-in-csv-field/70994 "2024-11-08T11:35:47Z")

</div>

I am doing data driven testing with Postman. And i am updating the expected results in the csv data file itself along with the input data. For a particular field, among the total of 10 iterations 7 iterations have values…

---

## [Check that each datetime in array is between specified datetimes](https://community.postman.com/t/check-that-each-datetime-in-array-is-between-specified-datetimes/68010)

<div class="topic-metadata">

**Author:** [@bethhalstead-meijer](https://community.postman.com/u/bethhalstead-meijer)\
**Replies:** 1\
**Last updated:** [September 5, 2024, 3:43pm UTC](https://community.postman.com/t/check-that-each-datetime-in-array-is-between-specified-datetimes/68010 "2024-09-05T15:43:12Z")

</div>

I am calling an endpoint using before and after timestamp parameters like this: {{baseUrl}}/activity?before=2024-09-04T13:55:02.325Z&after=2024-09-03T12:34:47.830Z Response body would be served as an array like this: \[…

---

## [Check key/value pair exists in each twice-nested array](https://community.postman.com/t/check-key-value-pair-exists-in-each-twice-nested-array/67925)

<div class="topic-metadata">

**Author:** [@bethhalstead-meijer](https://community.postman.com/u/bethhalstead-meijer)\
**Replies:** 1\
**Last updated:** [September 4, 2024, 2:59pm UTC](https://community.postman.com/t/check-key-value-pair-exists-in-each-twice-nested-array/67925 "2024-09-04T14:59:08Z")

</div>

Test that each changes array has property = active I am trying to write a test that checks each changes object in the JSON response body for property = active. In other words, each changes array within the response sho…

---

## [Check each nested object contains a value in one of two objects](https://community.postman.com/t/check-each-nested-object-contains-a-value-in-one-of-two-objects/67755)

<div class="topic-metadata">

**Author:** [@bethhalstead-meijer](https://community.postman.com/u/bethhalstead-meijer)\
**Replies:** 1\
**Last updated:** [August 31, 2024, 11:09am UTC](https://community.postman.com/t/check-each-nested-object-contains-a-value-in-one-of-two-objects/67755 "2024-08-31T11:09:31Z")

</div>

Test that each nested and unnamed object has prior=248 or new=248 I am trying to write a test that checks each of the objects in the JSON response body for a specific string (in this case ‘248’) in either the ‘changes.p…

---

## [Combining multiple assertion steps into a single step](https://community.postman.com/t/combining-multiple-assertion-steps-into-a-single-step/59879)

<div class="topic-metadata">

**Author:** [@kayal1postman](https://community.postman.com/u/kayal1postman)\
**Replies:** 2\
**Last updated:** [April 12, 2024, 1:41pm UTC](https://community.postman.com/t/combining-multiple-assertion-steps-into-a-single-step/59879 "2024-04-12T13:41:44Z")

</div>

Hi , Below is my multiple lines of code for asserting whether object got these properties. Is there any way that I can rewrite into a single line code please. your assistance is much appreciated. pm.expect(json.Risk).t…

---

## [Response value is same as in the request sent](https://community.postman.com/t/response-value-is-same-as-in-the-request-sent/59802)

<div class="topic-metadata">

**Author:** [@kayal1postman](https://community.postman.com/u/kayal1postman)\
**Replies:** 1\
**Last updated:** [April 10, 2024, 4:21pm UTC](https://community.postman.com/t/response-value-is-same-as-in-the-request-sent/59802 "2024-04-10T16:21:44Z")

</div>

Hi, I need to write automated test for the API response. The response contains values which are same as what I have sent as an request. I need to ensure that what I sent is been added in the database and reflected bac…

---

## [+ive, -ive test for Response body containing element & array](https://community.postman.com/t/ive-ive-test-for-response-body-containing-element-array/58907)

<div class="topic-metadata">

**Author:** [@shailendrakumaromkar](https://community.postman.com/u/shailendrakumaromkar)\
**Replies:** 2\
**Last updated:** [March 17, 2024, 8:26pm UTC](https://community.postman.com/t/ive-ive-test-for-response-body-containing-element-array/58907 "2024-03-17T20:26:14Z")

</div>

My response body is below, how can I write below tests - Response body contains elements (‘oldestBlock’,‘reward’, ‘baseFeePerGas’,‘gasUsedRatio’), in a single test I tried below but it should fail instead of pass bec…

---

## [AssertionError When Matching URL Against Regex in Postman Te](https://community.postman.com/t/assertionerror-when-matching-url-against-regex-in-postman-te/55770)

<div class="topic-metadata">

**Author:** [@eldor488](https://community.postman.com/u/eldor488)\
**Replies:** 1\
**Last updated:** [December 22, 2023, 1:57pm UTC](https://community.postman.com/t/assertionerror-when-matching-url-against-regex-in-postman-te/55770 "2023-12-22T13:57:43Z")

</div>

Hi everyone, I’m writing a test in Postman and encountering an AssertionError. I want to validate that my request URL follows the pattern /books/{id}, where {id} is a UUID. Assertion Error: \[checkout a book\] path is s…

---

## [How to check in json schema validation that response doesnt contains any extra fields that wasn't declorated by me in json schema validation?](https://community.postman.com/t/how-to-check-in-json-schema-validation-that-response-doesnt-contains-any-extra-fields-that-wasnt-declorated-by-me-in-json-schema-validation/46356)

<div class="topic-metadata">

**Author:** [@egoriacovlevorange](https://community.postman.com/u/egoriacovlevorange)\
**Replies:** 3\
**Last updated:** [November 14, 2023, 8:14am UTC](https://community.postman.com/t/how-to-check-in-json-schema-validation-that-response-doesnt-contains-any-extra-fields-that-wasnt-declorated-by-me-in-json-schema-validation/46356 "2023-11-14T08:14:24Z")

</div>

Hello guys! I have trouble in json schema validation. I tried to use all of validators and i found that them doesn’t show error message, while response from api have some extra fields that was not declorated by me. fo…

---

## [Check if array contains 'true' or 'false' flag in Response](https://community.postman.com/t/check-if-array-contains-true-or-false-flag-in-response/48552)

<div class="topic-metadata">

**Author:** [@gonsag](https://community.postman.com/u/gonsag)\
**Replies:** 6\
**Last updated:** [June 19, 2023, 10:32pm UTC](https://community.postman.com/t/check-if-array-contains-true-or-false-flag-in-response/48552 "2023-06-19T22:32:29Z")

</div>

Hi team, I have an array which contains the flag as : \[false, true, false\] and so on. I wrote code to fetch out using contains, include, have.property and others as an ‘if’ condition and unable to trigger the condition …

---

## [POST Response Assertion to search through all ITEM.s to return a value if found](https://community.postman.com/t/post-response-assertion-to-search-through-all-item-s-to-return-a-value-if-found/41537)

<div class="topic-metadata">

**Author:** [@RyanHamilton00](https://community.postman.com/u/RyanHamilton00)\
**Replies:** 2\
**Last updated:** [November 30, 2022, 3:59pm UTC](https://community.postman.com/t/post-response-assertion-to-search-through-all-item-s-to-return-a-value-if-found/41537 "2022-11-30T15:59:52Z")

</div>

My question: I am trying to validate a POST Response, I get many results and I just want to confirm if the value exists and move on. I suspect this is an often-wanted assertion so I am pretty confident I am making it t…

---

## [Is there any way to continue with tests in postman even if any one assert fails in it?](https://community.postman.com/t/is-there-any-way-to-continue-with-tests-in-postman-even-if-any-one-assert-fails-in-it/14583)

<div class="topic-metadata">

**Author:** [@svarshney2311](https://community.postman.com/u/svarshney2311)\
**Replies:** 8\
**Last updated:** [March 22, 2022, 6:34am UTC](https://community.postman.com/t/is-there-any-way-to-continue-with-tests-in-postman-even-if-any-one-assert-fails-in-it/14583 "2022-03-22T06:34:13Z")

</div>

In a Postman GET request, I have used multiple assertions. However, if any assertion fails, Postman will stops its execution then and there and will throw an error. Is there any way to prevent this and continue with oth…

---

## [The Postman Cheatsheet & Quick Reference Guide (2021)](https://community.postman.com/t/the-postman-cheatsheet-quick-reference-guide-2021/1054)

<div class="topic-metadata">

**Author:** [@vdespa](https://community.postman.com/u/vdespa)\
**Replies:** 12\
**Last updated:** [March 4, 2022, 2:06pm UTC](https://community.postman.com/t/the-postman-cheatsheet-quick-reference-guide-2021/1054 "2022-03-04T14:06:16Z")

</div>

Hey community, I have created a document called Postman Quick Reference Guide, which is practically a collection of things I often stumble upon while using Postman and need a quick answer to. This is still kind of work…

---

## [Trying to assert empty/null/undefined value with no luck](https://community.postman.com/t/trying-to-assert-empty-null-undefined-value-with-no-luck/28958)

<div class="topic-metadata">

**Author:** [@amy6586](https://community.postman.com/u/amy6586)\
**Replies:** 6\
**Last updated:** [October 22, 2021, 8:56am UTC](https://community.postman.com/t/trying-to-assert-empty-null-undefined-value-with-no-luck/28958 "2021-10-22T08:56:23Z")

</div>

Hello! I’m fairly new to Postman and I’m not a Mocha expert, I’m using the “Using CSV” data to load a file with the data I need and that is working perfectly, my problem is that I need to assert one of the fields and I …

---

## [Postman throws "AssertionError" in console and Test Results pane instead of failed test](https://community.postman.com/t/postman-throws-assertionerror-in-console-and-test-results-pane-instead-of-failed-test/28216)

<div class="topic-metadata">

**Author:** [@jprealini](https://community.postman.com/u/jprealini)\
**Replies:** 1\
**Last updated:** [September 28, 2021, 5:52pm UTC](https://community.postman.com/t/postman-throws-assertionerror-in-console-and-test-results-pane-instead-of-failed-test/28216 "2021-09-28T17:52:17Z")

</div>

Hi! I have a strange case In one test, after making the main request, I have to make an extra api request to validate that the main request updated some info correctly So I go something like pm.sendRequest(SCAN\_REQUES…

---

## [Assertion for checking key name (array) in request body?](https://community.postman.com/t/assertion-for-checking-key-name-array-in-request-body/28046)

<div class="topic-metadata">

**Author:** [@trangntt19hcm](https://community.postman.com/u/trangntt19hcm)\
**Replies:** 2\
**Last updated:** [September 23, 2021, 2:57am UTC](https://community.postman.com/t/assertion-for-checking-key-name-array-in-request-body/28046 "2021-09-23T02:57:43Z")

</div>

I have Request Body as below (Reality, I will request more than 100 key names ) and I want to check all key names requested are present or not? But I got a problem with handling array “errors” =\> Have any advice for me? …

---

## [An assertion to check whether the array in the response body match with a JSON file](https://community.postman.com/t/an-assertion-to-check-whether-the-array-in-the-response-body-match-with-a-json-file/26603)

<div class="topic-metadata">

**Author:** [@docking-module-geos3](https://community.postman.com/u/docking-module-geos3)\
**Replies:** 1\
**Last updated:** [August 11, 2021, 10:18am UTC](https://community.postman.com/t/an-assertion-to-check-whether-the-array-in-the-response-body-match-with-a-json-file/26603 "2021-08-11T10:18:40Z")

</div>

Hi, I want to add an assertion to check whether the array in the response body match with a JSON file In the below example, I have an array “ErrorCode” with 3 elements (in reality, there are a lot of returned data so I…

---

## [To assert that the array in the response body contains a substring string value in all its elements](https://community.postman.com/t/to-assert-that-the-array-in-the-response-body-contains-a-substring-string-value-in-all-its-elements/26341)

<div class="topic-metadata">

**Author:** [@scottadamspm](https://community.postman.com/u/scottadamspm)\
**Replies:** 3\
**Last updated:** [August 2, 2021, 1:57pm UTC](https://community.postman.com/t/to-assert-that-the-array-in-the-response-body-contains-a-substring-string-value-in-all-its-elements/26341 "2021-08-02T13:57:46Z")

</div>

Hi, New to Postman and finding this assertion very difficult to code. In the example below, I have an array Customer with 3 elements. I want to check if the firstName or LastName of each element starts with “JO”, “ADA…

---

## [Assertions for API Test scripts](https://community.postman.com/t/assertions-for-api-test-scripts/8717)

<div class="topic-metadata">

**Author:** [@gayaniw](https://community.postman.com/u/gayaniw)\
**Replies:** 1\
**Last updated:** [July 22, 2021, 6:25pm UTC](https://community.postman.com/t/assertions-for-api-test-scripts/8717 "2021-07-22T18:25:54Z")

</div>

API Assertions API testing is all about assertions. There are two steps to write assertions Parse the response body Write the test Response body may come as a JSON, XML,HTML, Plain text or CSV. But the common format …

---

## [To assert that the array in the response body contains a string value in all its elements](https://community.postman.com/t/to-assert-that-the-array-in-the-response-body-contains-a-string-value-in-all-its-elements/10017)

<div class="topic-metadata">

**Author:** [@LearningPostmanR](https://community.postman.com/u/LearningPostmanR)\
**Replies:** 30\
**Last updated:** [June 24, 2021, 11:40am UTC](https://community.postman.com/t/to-assert-that-the-array-in-the-response-body-contains-a-string-value-in-all-its-elements/10017 "2021-06-24T11:40:12Z")

</div>

Hi, New to Postman and not accustomed to writing code so please help. Couldn’t find any similar post either which I could use. I want to add an assertion to check whether a value is present in all the elements in an ar…

---

## [Assert contains multiple strings](https://community.postman.com/t/assert-contains-multiple-strings/7383)

<div class="topic-metadata">

**Author:** [@e.mikhailov](https://community.postman.com/u/e.mikhailov)\
**Replies:** 7\
**Last updated:** [May 31, 2021, 8:38pm UTC](https://community.postman.com/t/assert-contains-multiple-strings/7383 "2021-05-31T20:38:39Z")

</div>

How to assert that variable contains multiple strings? Something like pm.expect(myText).to.include("text1", "text2"); Is there a ready-made solution without looping?

---

## [Verify the first Json response Object values are present in second Json Response Object values](https://community.postman.com/t/verify-the-first-json-response-object-values-are-present-in-second-json-response-object-values/20142)

<div class="topic-metadata">

**Author:** [@bhasker.vade](https://community.postman.com/u/bhasker.vade)\
**Replies:** 4\
**Last updated:** [February 8, 2021, 9:07pm UTC](https://community.postman.com/t/verify-the-first-json-response-object-values-are-present-in-second-json-response-object-values/20142 "2021-02-08T21:07:27Z")

</div>

Hello Team , can someone please help me here I have 2 Json Reponses , I need to verify that first objects value are present in Second objects values first object name and second object name are different in first…

---

## [Need help creating assertions for test](https://community.postman.com/t/need-help-creating-assertions-for-test/19212)

<div class="topic-metadata">

**Author:** [@Straub2148](https://community.postman.com/u/Straub2148)\
**Replies:** 14\
**Last updated:** [January 21, 2021, 12:29pm UTC](https://community.postman.com/t/need-help-creating-assertions-for-test/19212 "2021-01-21T12:29:50Z")

</div>

I’m new to Postman and do not have any coding experience. How would I go about creating assertions to verify values for “name”, “latitude”, “upperLimit” and “lowerLimit” in the code below? { “@type”: “AntennaConfig”, …

---

## [I am unable to assert french text](https://community.postman.com/t/i-am-unable-to-assert-french-text/17431)

<div class="topic-metadata">

**Author:** [@nishant.shah2](https://community.postman.com/u/nishant.shah2)\
**Replies:** 3\
**Last updated:** [November 9, 2020, 12:46pm UTC](https://community.postman.com/t/i-am-unable-to-assert-french-text/17431 "2020-11-09T12:46:46Z")

</div>

I am trying to assert a response text which is in French language. But, the assert is not successful even though both actual and expected texts are exactly the same. this is the code I am using : pm.expect(translation…

---

## [Best approach to asserting values in arrays within arrays within arrays](https://community.postman.com/t/best-approach-to-asserting-values-in-arrays-within-arrays-within-arrays/15373)

<div class="topic-metadata">

**Author:** [@imageekgirl](https://community.postman.com/u/imageekgirl)\
**Replies:** 0\
**Last updated:** [August 27, 2020, 6:29pm UTC](https://community.postman.com/t/best-approach-to-asserting-values-in-arrays-within-arrays-within-arrays/15373 "2020-08-27T18:29:03Z")

</div>

I am setting up a test suite for GraphQL endpoints and am getting a “false pass” or a test that should have failed when I “tested my test” but is passing, so there is obviously something wrong. I have seen a few example…

---

## [Check Response body contains Match value](https://community.postman.com/t/check-response-body-contains-match-value/14622)

<div class="topic-metadata">

**Author:** [@Bhaumik](https://community.postman.com/u/Bhaumik)\
**Replies:** 5\
**Last updated:** [August 6, 2020, 12:05pm UTC](https://community.postman.com/t/check-response-body-contains-match-value/14622 "2020-08-06T12:05:43Z")

</div>

I am new to postman My Response Body is like something i want to check first name is match or not ? can anyone help ? { "status": true, "status\_code": 200, "data": { "first\_name": { "result": "Match" …

---

## [Response Assertion API in test scripts](https://community.postman.com/t/response-assertion-api-in-test-scripts/596)

<div class="topic-metadata">

**Author:** [@Kency](https://community.postman.com/u/Kency)\
**Replies:** 1\
**Last updated:** [July 5, 2018, 8:07pm UTC](https://community.postman.com/t/response-assertion-api-in-test-scripts/596 "2018-07-05T20:07:20Z")

</div>

Hello, I was using the below as mentioned in the postman documentation: pm.response.to.be.badRequest The request that I fire is actually giving me a Bad Request but somehow the assertion failed with the below message: …
