API Testing Course - Question about task #2

Good day

I am doing the tasks for the course of the postman of Mr. Valentin Despa. I have a problem that I cannot understand. The test does not pass because of the API key, but I do not know where to get it. I entered 1) the collection key, 2) my key, but where can I get the API key?


I would be very grateful for your help.

Hey @aerospace-geoscien20 :waving_hand:t2:

The apiKey in that context, isn’t anything to do with the Postman API Key, just so you can rule that out.

What’s returned from the Register a new client request?

Hello, I solved my problem. It was not the key, but the test. It was

pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});

but there wasn’t such a thing

pm.test("Status code is 200", function () {
    pm.expect(pm.response.code).to.eql(200);
});
1 Like

Those tests are slightly different implementations of the same thing.

They should both work.

The pm.expect is using Chai JS as the assertion library.

Where the pm.response.to.have.status is using methods added to the pm.response function.

If you console log pm.response directly, you will get something like the following.

The tooltip for pm.response.to.have.status shows the following.

(method) AssertableHave.status(code: number): any (+1 overload)

So its actually looking for the code key (not the status key).

On paper, both of your tests should pass.

Thank you very much
Thank you very much