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!