Day 02 - Issues submitting solution

Day 02 - Submit Response - POST raw text (instructions here)

Any help is appreciated:

I have set-up the API as secret {{postman_api_key}} variable per the instructions. It didn’t like this - complaining about exposing the KEY. So I used the ‘wizard’ to create a POSTMAN_API environment with the key - value pair

Both seem to work but is confusing what I’m supposed to do.

Regardless - I send a POST request (CURL below)"

curl --location --request POST 'https://api.getpostman.com/collections/27267296-9f9f0d2a-49b8-4691-8be1-4416216dcac6' \
--header 'x-api-key: ••••••' \
--header '<**!!!MY API KEY IN RAW TEXT!!!!**>;'

and get these FAILED TESTS:

FAILCorrect collection returned | AssertionError: Target cannot be null or undefined.
FAILOld request updated | TypeError: Cannot read properties of undefined (reading 'item')|Fix test
FAILNew request added | AssertionError: Target cannot be null or undefined.

I looked & don’t see what I am missing

RAW LOG

POST https://api.getpostman.com/collections/27267296-9f9f0d2a-49b8-4691-8be1-4416216dcac6: {
  "Network": {
    "addresses": {
      "local": {
        "address": "10.10.10.24",
        "family": "IPv4",
        "port": 63542
      },
      "remote": {
        "address": "18.209.71.189",
        "family": "IPv4",
        "port": 443
      }
    },
    "tls": {
      "reused": true,
      "authorized": true,
      "authorizationError": null,
      "cipher": {
        "name": "ECDHE-RSA-AES128-GCM-SHA256",
        "standardName": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
        "version": "TLSv1/SSLv3"
      },
      "protocol": "TLSv1.2",
      "ephemeralKeyInfo": {},
      "peerCertificate": {
        "subject": {
          "commonName": "postman.com",
          "alternativeNames": "DNS:postman.com, DNS:*.postman.com, DNS:*.srv.postman.com, DNS:*.explore.postman.com, DNS:*.postman.co, DNS:*.cdn.postman.com, DNS:postman.co, DNS:*.mac.postman.com, DNS:*.id.postman.com, DNS:*.gw.postman.com, DNS:*.go.postman.com, DNS:*.getpostman.com, DNS:getpostman.com"
        },
        "issuer": {
          "country": "US",
          "organization": "Amazon",
          "commonName": "Amazon RSA 2048 M03"
        },
        "validFrom": "Aug 12 00:00:00 2023 GMT",
        "validTo": "Sep  9 23:59:59 2024 GMT",
        "fingerprint": "42:78:49:20:2E:E1:03:B9:42:CA:28:4E:05:31:3D:C5:98:63:2C:37",
        "serialNumber": "02b64ce8f1fbca9b6181b0a89019041d"
      }
    }
  },
  "Request Headers": {
    "x-api-key": "PMAK-XX",
    "user-agent": "PostmanRuntime/7.36.0",
    "accept": "*/*",
    "postman-token": "1c2e293d-f1ff-49e9-89a6-4cdfde446c43",
    "host": "api.getpostman.com",
    "accept-encoding": "gzip, deflate, br",
    "connection": "keep-alive",
    "content-length": "0"
  },
  "Response Headers": {
    "date": "Wed, 13 Dec 2023 14:51:09 GMT",
    "content-type": "application/json; charset=utf-8",
    "content-length": "70",
    "connection": "keep-alive",
    "x-frame-options": "SAMEORIGIN",
    "access-control-allow-origin": "*",
    "x-srv-trace": "v=1;t=12d29087500ef0ef",
    "x-srv-span": "v=1;s=bfcacf6e25170e40",
    "etag": "W/\"46-9aD1jZThNU4PUOTjNGN6oaM20gs\"",
    "vary": "Accept-Encoding"
  },
  "Response Body": "{\"error\":{\"name\":\"notFound\",\"message\":\"Requested resource not found\"}}"
}

Hey @flight-cosmologist-3 :wave:

Welcome to the Postman Community! :postman:

This is instructions for that Day’s challenge:

Take a look at the names that you have given the request and what the instructions state:

image

Also, I’m not sure how you have changed the name of the submit request and added another request, in the second folder :thinking:

This are the instructions for the submit request:

The fails you have see in the test, looks like a 404 response. You hit the Postman API but you may not have used the correct Collection Id. This would be the Id of the Day 02: Collections and environments Collection.

Thank you for the prompt reply…

hmm, I guess I got a bit confused…

I renamed the two but still getting confused on the ‘submit’

I am pretty sureI am using the correct ID: 27267296-9f9f0d2a-49b8-4691-8be1-4416216dcac6

image.png

I set it as a variable {{collectionID}} as well as ‘hardcoded’ in the URL - same errors…

I changed from POST to GET and am seeing the data ‘test code’ is looking for so I guess I have the ID & API right…

I’m at a loss…

I’m sorry - I just don’t see what I’m missing here…

What’s the response that you get now, from that submit request using the correct api key details?

Do you have the environment selected when you have added the details?

Thanks again Danny!! The Test response is exactly the same.despite ‘fixing’ it

I’ve attached the console output for the PUT and GET

I’m sure it’s me…

(Attachment GET httpsapi.getpostman.comcollecti.txt is missing)

(Attachment PUT console.txt is missing)

The Postman Console out isn’t helpful in this context, just share a screenshot of the app showing the response pane, which includes the status code and response body.

Also, be mindful of how that console output is shown in the thread messages, enclose these details in a code block to make it easier to read.

ah, sorry, Here’s the screenshot.

and here’s the test results:

The submit request should be a GET not a POST. It was likely changed when you added that other requests there.

The first test is failing as it’s unable to confirm that it’s testing against the correct Collection. That would then have a knock on effect.

THANK YOU Danny!!

I suspected GET was right - I think I know where I went wrong but not going to try explaining or justifying it…

BUT I should mention. I had to change the test code to work - for instance the ‘bad’ test had this:

pm.test(‘Status code is 200’, () => {
pm.response.to.have.status(404);
pass += 1;
})

…and was always looking for a 404 - so when I used ‘PUT’ it tested OK.

Can’t mention how much I learned about POSTMAN today, thanks to you!!

1 Like

No worries. We’re here to help. :pray:t2:

If you have changed any code in those collections to pass a day’s task, be aware that your overall Submission for the badge is likely to fail, when checked against the final checks that we run the automation against.

There shouldn’t be any need to change the test code, if there is, that means that you haven’t fully completed the days challenge correctly.

1 Like

This is the original collection.

submit | 30 days of Postman - for developers | Postman API Network

pm.test("Status code is 200", () => {
    pm.response.to.have.status(200);
    pass += 1
});

You might want to copy all of the code from the tests tab, and replace what you have currently to ensure its correct, otherwise it will potentially fail the final submission.

1 Like

Good idea Mike - I did that & everything tested OK!!!

Thanks all!