title: How do I write a Postman test to verify that a request returns '400 Bad Request'?
body: <p>I need a test case that verifies that a '400 Bad Request' is returned when an API call is made without the required field. (Previously there was a bug where the field was needed, but requests without were being accepted) </p>
  
  <p>It's a simple POST call with auth and a raw body. It returns a 200 when the missing field is returned.</p>
  
  <p>The POST returns the '400 Bad Request' correctly, but I can't get the test to pass.</p>
  
  <p>The following tests all fail:</p>
  
  <pre><code>pm.test("Status is an error", function () {
      pm.response.to.be.error;
  });
  </code></pre>
  
  <pre><code>pm.test("Status code is 400", function () {
      pm.response.to.have.status(400);
  });
  </code></pre>
  
  <p>The response body is:</p>
  
  <pre><code>Instantiation of [simple type, class com.[company].[product].notifications.api.v2.models.NotificationCreateV2] value failed for JSON property content due to missing (therefore NULL) value for creator parameter content which is a non-nullable type
   at [Source: (byte[])"{
    "field1": "string",
    "field2": "Snort",
    "field3": "Signature 5102",
    "field4": "2019-04-19T10:34:03Z",
    "field5": 0,
    "field6": 4
  }"; line: 8, column: 1] (through reference chain: com.[company].[product].notifications.api.v2.models.NotificationCreateV2["content"])
  </code></pre>