Error in submissions of Postman API Fundamentals Student Expert certification

I’m submitting the postman examples, however, errors returned in the ‘Add a book’ request. However, the errors are referencing what I believe is a request that includes parameters - movies in the request which is not part of ‘adding a book’.


{
“status”: “error”,
“message”: “Your collection failed one or more Postman tests. See the errors array for details.”,
“errors”: [
{
“test”: “[add a book] has script in Tests tab”,
“message”: “Cannot read properties of undefined (reading ‘length’)”
},
{
“test”: “1. [skillcheck] Used POST as the request method”,
“message”: “Cannot read properties of undefined (reading ‘request’)”
},
{
“test”: “2. [skillcheck] Used a query parameter called ‘movieName’”,
“message”: “Cannot read properties of undefined (reading ‘request’)”
},
{
“test”: “3. [skillcheck] Used a base URL variable called {{skillcheckBaseUrl}}”,
“message”: “Cannot read properties of undefined (reading ‘request’)”
},
{
“test”: “4. [skillcheck] Set request auth to “API key” & header to “student-expert"”,
“message”: “Cannot read properties of undefined (reading ‘request’)”
},
{
“test”: "5. [skillcheck] Used a JSON body with 'actorName; ",
“message”: “Cannot read properties of undefined (reading ‘request’)”
},
{
“test”: “6. [skillcheck] Set "favoriteActor" as a collection variable using pm.collectionVariables set(…) in Tests tab script”,
“message”: “Cannot read properties of undefined (reading ‘event’)”
}
]
}

This means it can’t read the response. All of the errors are likely to be related to the same issue.

Check the response for the submit request. It should return your collection as JSON.

I suspect its failing the authentication, or something similar.

Yes, I know it cannot read the response. However, when I submit the same request, I get a successful 201 response. See below the response:

{
“id”: “f976323b-5f38-47e4-92ff-7efed38739b4”,
“title”: “To Kill a Mockingbird”,
“author”: “Harper Lee”,
“genre”: “fiction”,
“yearPublished”: 1960,
“checkedOut”: false,
“isPermanentCollection”: false,
“createdAt”: “2023-07-05T19:08:01.570Z”
}

However, when I submit it back as part of the submission for certification, I get an error. But the errors are the thing that confused me.

“test”: “2. [skillcheck] Used a query parameter called ‘movieName’”,
“message”: “Cannot read properties of undefined (reading ‘request’)”

Talks about a query parameter - ‘movieName’ which is not part of the request. See below:

Request Headers

Content-Type: application/json

api-key: postmanrulz

User-Agent: PostmanRuntime/7.32.3

Accept: /

Cache-Control: no-cache

Postman-Token: 5d2323ea-f429-4557-b0d6-60ebae8eb574

Host: library-api.postmanlabs.com

Accept-Encoding: gzip, deflate, br

Connection: keep-alive

:arrow_forward:Request Body

{ “title”: “To Kill a Mockingbird”, “author”: “Harper Lee”, “genre”: “fiction”, “yearPublished”: 1960 }

I don’t have access to this course, so I don’t know what it asks.

I’m not even sure if its the same format as the other training courses. (I understand this course was updated recently).

With the other courses, you have a bunch of individual requests that you have to create or amend.

With a separate sub-folder with the submit request.

It doesn’t matter if the individual requests are passing.

It’s the submit request, which should be returning a JSON response of the entire collection details.

The submit request has a bunch of tests in the tests tab that assert on elements within that collection JSON.

I can’t comment on the movieName parameter as I can’t see the course details but the errors are all coming back as undefined which usually means it can’t read the response at all (or its not in the expected format). So my recommendation would be to fix that bit first.

The first step is to check is whether the collection is actually being returned. That you are not getting authentication errors (401) which is the usual suspect here related to how the API key has been added.

Hi,
I’ve resolved the issue - user error. Failing to read the section that describes skill checks which includes movieName.

I too getting the same error even after passing all the tests in both final or halfway check.

{
    "status": "error",
    "message": "Your collection failed one or more Postman tests. See the errors array for details.",
    "errors": [
        {
            "test": "6. [skillcheck] Set \"favoriteActor\" as a collection variable using pm.collectionVariables set(...) in  Tests tab script",
            "message": "Cannot read properties of undefined (reading 'filter')"
        }
    ]
}

Can you share your script that you have used to set that value as a Collection Variable?

You’re just showing the outcome of the submit request and not the area of the code that sets the variable.

Can you include screenshots of the Collection and scripts that show this please.

Hi there,

In my case, I got this error

{
“status”: “error”,
“message”: “Your collection failed one or more Postman tests. See the errors array for details.”,
“errors”: [
{
“test”: “[get fiction books] query parameters for genre=fiction and checkedOut=false are both set with the correct values”,
“message”: “expected false to equal true”
}
]
}

Meanwhile in GET Final check, Test Results was 28/28


Here’s the aspect of the script that concerns get fiction book:

/** 2. get fiction books */
const req2 = reqs[1];

// Check if the request method is GET
pm.test(“[get fiction books] is a GET request”, function () {
pm.expect(req2.request.method, “Fix: Change the method to GET”).to.equal(“GET”);
});

// Check if the base URL is set to {{baseUrl}}
pm.test([get fiction books] base URL is set to {{baseUrl}}, function () {
const pattern = /^{{baseUrl}}/i;
const url = req2.request.url.raw || req2.request.url;
pm.expect(url.trim(), Fix: Set the base URL to "{{baseUrl}}").to.match(pattern);
});

// Check if the path is set to /books
pm.test(“[get fiction books] path is set to /books”, function () {
const pattern = //books??/;
const url = req2.request.url.raw || req2.request.url;
pm.expect(url.trim(), Fix: Path should be "{{baseUrl}}/books").to.match(pattern);
});

// Check Query Params
pm.test(“[get fiction books] Check Query Params”, function () {
const queryParams = req2.request.url.query;
console.log(“Query Parameters:”, queryParams);

const genreParam = queryParams.some(q => q.key === 'genre' && q.value === 'fiction');
const checkOutParam = queryParams.some(q => q.key === 'checkOut' && q.value === 'false');

console.log("Genre Parameter Exists:", genreParam);
console.log("CheckOut Parameter Exists:", checkOutParam);

pm.expect(genreParam, `Fix: Query Param "genre" should be "fiction"`).to.be.true;
pm.expect(checkOutParam, `Fix: Query Param "checkOut" should be "false"`).to.be.true;

});

I have done all debugging, yet still could not figure it out. Kindly assist