Disable AssertionError when received status code 201

I’m getting the below error when receiving a 201 response code from a successful post.

Status code is 200 | AssertionError: expected response to have status code 200 but got 201

Is there a way to supress this, as the request has been successful?

Hey @jazzycow ,

Welcome to the community :wave:

Are you getting this error from one of your tests, if so, can you share more detailed information so that we can help you change it?
Or you can use this way,

 pm.test("Successful POST request", function () {

For example the screenshot and test block where you get this error.

Another method that could be used to pass anything that returns a 2XX code is this:


The way that @yusuftaymann described is great if you want to limit that range to be specific codes. :trophy:

1 Like

OH, appologies for this. I had a folder defined with a test, that checked for status code of 200, not 201.

Luckly I posted this on the ‘noobs’ category :slight_smile:

I’ve completely forgotten that I’ve defined that there and when you get into inheritance you get cofused quickly.

Thanks for the prompt response.

1 Like

Thanks for the tip. I’ve used it now.

1 Like