Day 3 - 30 days of Postman - test failed, why?

Hi there!

I have started the 30 days of postman training but I’m stuck on the 3rd day already. I can’t find out why.

I’ve done the whole thing several times with a new API key, new ID etcetera.
This is the error I get;

I checked if I have the right ID, I have the API key. Does someone know what I’m doing wrong?

Thanks!

Hey @abeekman :wave:

Welcome to the Postman community :postman:

Could you also share an image of the full app window including the address bar please?

Did you have any issues submitting the previous days challenge?

Thank you!


Is this what you mean?

No, no other issues. Everything was working fine :slight_smile:

What’s the response code from that request?

Can you also check the Postman Console and inspect the headers of that request to ensure its sending the correct token, using the correct key.

If its a 200 code, like the previous image, the Collection Id could be wrong. Worth re checking that you’re not using the request or folder id instead.

I get this image

And the text:

{
    "collection": {
        "info": {
            "_postman_id": "bf5e034b-1d9f-4a3d-82f0-9e48791b2b6c",
            "name": "Day 03: Add request details",
            "description": "**Deleted it so it's readable**",
            "schema": "https:// schema. getpostman. com/json/collection/v2.1.0/collection.json",
            "fork": {
                "label": "Anne's fork",
                "createdAt": "2021-04-07T19:19:40.000Z",
                "from": "1559645-969f4824-25ba-4ed6-8926-f71ce4ee079d"
            },
            "updatedAt": "2023-12-07T14:13:29.000Z",
            "uid": "31658839-bf5e034b-1d9f-4a3d-82f0-9e48791b2b6c"
        },
        "item": [
            {
                "name": "Add request details",
                "item": [
                    {
                        "name": "New Request",
                        "id": "d26a7a70-ef41-4d61-8566-465f49caa6d5",
                        "protocolProfileBehavior": {
                            "disableBodyPruning": true
                        },
                        "request": {
                            "method": "POST",
                            "header": [],
                            "url": {
                                "raw": "{{baseURL}}/post",
                                "host": [
                                    "{{baseURL}}"
                                ],
                                "path": [
                                    "post"
                                ]
                            }
                        },
                        "response": [],
                        "uid": "31658839-d26a7a70-ef41-4d61-8566-465f49caa6d5"
                    }
                ],
                "id": "0144fc58-2b8b-4d88-8a80-5486e3bb4887",
                "description": "**Deleted it so it's readable**",
                "uid": "31658839-0144fc58-2b8b-4d88-8a80-5486e3bb4887"
            },
            {
                "name": "Submit your solution",
                "item": [
                    {
                        "name": "submit",
                        "event": [
                            {
                                "listen": "test",
                                "script": {
                                    "id": "06bd2391-e094-41a3-83de-35b4cb3ed622",
                                    "exec": [
                                        "// counter for passed tests\r",
                                        "let pass = 0\r",
                                        "let totalToPass = 5\r",
                                        "\r",
                                        "let collection = pm.response.json().collection\r",
                                        "\r",
                                        "pm.test(\"If you have any failures, review the failed test results or ask for support in the community forum. Remember to save your changes if you update the collection. When all of your tests pass, you are done with today's challenge.\", () => {\r",
                                        "    pm.expect(true);\r",
                                        "    pass += 1\r",
                                        "});\r",
                                        "\r",
                                        "pm.test(\"Status code is 200\", () => {\r",
                                        "    pm.response.to.have.status(200);\r",
                                        "    pass += 1\r",
                                        "});\r",
                                        "\r",
                                        "pm.test(\"Correct collection returned\", () => {\r",
                                        "    pm.expect(collection.info.name).equals(\"Day 03: Add request details\")\r",
                                        "    pass += 1\r",
                                        "})\r",
                                        "\r",
                                        "let folder = collection.item.find(fol => { return fol.name == \"Add request details\"})\r",
                                        "\r",
                                        "pm.test(\"Request added correctly\", () => {\r",
                                        "    pm.expect(folder.item.length, 'check number of requests').is.greaterThan(0)\r",
                                        "\r",
                                        "    let newRequest = folder.item.find(req => { return req.name === \"raw JSON body\"})\r",
                                        "\r",
                                        "    pm.expect(newRequest.name, 'check name').equals(\"raw JSON body\")\r",
                                        "    pm.expect(newRequest.request.method, 'check method').equals(\"POST\")\r",
                                        "    pass += 1\r",
                                        "})\r",
                                        "\r",
                                        "pm.test(\"JSON body correct\", () => {\r",
                                        "    let newRequest = collection.item[0].item.find(req => { return req.name === \"raw JSON body\"})\r",
                                        "\r",
                                        "    pm.expect(newRequest.request.body.mode, 'check mode').equals(\"raw\")\r",
                                        "    pm.expect(newRequest.request.body.options.raw.language, 'check language').equals(\"json\")\r",
                                        "    pm.expect(newRequest.request.body.raw, 'check json').to.not.be.empty\r",
                                        "    // TODO: add json schema validation\r",
                                        "    pass += 1\r",
                                        "})\r",
                                        "\r",
                                        "// visualization for test results\r",
                                        "let template\r",
                                        "if (pass == totalToPass) {\r",
                                        "    template = `🍪 passing!\r",
                                        "        <br />\r",
                                        "        \r",
                                        "    `\r",
                                        "} else {\r",
                                        "    template = `🙅 please try again\r",
                                        "        <br />\r",
                                        "        \r",
                                        "    `\r",
                                        "}\r",
                                        "pm.visualizer.set(template)"
                                    ],
                                    "type": "text/javascript"
                                }
                            }
                        ],
                        "id": "96d1278f-0331-4997-bb2d-c3c0508f7cda",
                        "protocolProfileBehavior": {
                            "disableBodyPruning": true
                        },
                        "request": {
                            "auth": {
                                "type": "apikey",
                                "apikey": [
                                    {
                                        "key": "value",
                                        "value": "PMAK-6571cc7a9466cf200b9253c0-19658fd68c9e3b796d040d11138XXXXX",
                                        "type": "string"
                                    },
                                    {
                                        "key": "key",
                                        "value": "X-API-Key",
                                        "type": "string"
                                    },
                                    {
                                        "key": "in",
                                        "value": "header",
                                        "type": "string"
                                    }
                                ]
                            },
                            "method": "GET",
                            "header": [],
                            "url": {
                                "raw": "https:// api. getpostman. com/collections/31658839-bf5e034b-1d9f-4a3d-82f0-9e48791b2b6c",
                                "protocol": "https",
                                "host": [
                                    "api",
                                    "getpostman",
                                    "com"
                                ],
                                "path": [
                                    "collections",
                                    "31658839-bf5e034b-1d9f-4a3d-82f0-9e48791b2b6c"
                                ]
                            },
                            "description": "**Deleted it so it's readable**"
                        },
                        "response": [],
                        "uid": "31658839-96d1278f-0331-4997-bb2d-c3c0508f7cda"
                    }
                ],
                "id": "87e52d32-cf2d-4029-bf05-05bcc53f2f45",
                "description": "Follow the instructions in the request documentation.",
                "uid": "31658839-87e52d32-cf2d-4029-bf05-05bcc53f2f45"
            }
        ],
        "auth": {
            "type": "apikey",
            "apikey": [
                {
                    "key": "value",
                    "value": "{{value}}",
                    "type": "string"
                },
                {
                    "key": "key",
                    "value": "{{key}}",
                    "type": "string"
                },
                {
                    "key": "in",
                    "value": "header",
                    "type": "string"
                }
            ]
        },
        "variable": [
            {
                "key": "value",
                "value": "",
                "type": "default"
            },
            {
                "key": "key",
                "value": "",
                "type": "default"
            },
            {
                "key": "in",
                "value": "",
                "type": "default"
            }
        ]
    }
}

I checked the API key and the ID (copied it from the collection details) and those should be the right ones

Could you share the Public link to your Workspace please, so we can take a look.

https://web.postman.co/workspace/Annes-Workspace~9d86c620-072e-446c-8f87-e4b62ae33a5d/overview
Can you access the link?

The Workspace would need to be Public for me or anyone else to view that.

It also looks like you haven’t got the correct request name within that folder. It should have one named - raw JSON body.

I can’t access that collection, but I can see the problem straight away.

Please re-read the instructions for the day and in particular what it tells you to call the request.

Add a request: Add a request to the folder Add request details called raw JSON body with the following details:

Wow I’m stupid. I tried it a few times, so I deleted the workspace and forgot to update the name indeed.
But thank you for your help. I received a happy cat yaay!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.