Logo
30 Day Challange API Documentation

Day 02: Collections and environments

Number of APIs: 3


Instructions for Day 2: Collections and environments

  1. Get the challenge: Fork [the parent collection Day 02: Collections and environments] to your own public workspace.
  2. Read the documentation: In your fork, select the first folder. Expand the context bar on the right to follow the instructions in the collection documentation. Remember, if you find it bothersome to navigate between the documentation while working in a different area of Qodex, you can open a new tab to keep your place in the documentation, and then switch between tabs.
  3. Submit your solution: Select the second folder Submit your solution and follow the instructions in the documentation to validate your solution.

Concepts covered

  • [Adding requests]
  • [Creating environments]
  • [Qodex API]

Additional resources

Next challenge

  • [Add request details]


1. Collections and environments - POST raw text

POST {{baseURL}}/post

It's time to work on your next challenge.

  1. Create a variable: Notice the same request from the last challenge. Copy the first part of the request URL (the part before /post) and replace it with {{baseURL}}.

The double curly braces is how you get variables in the text fields of Qodex. If you hover over the variable, the tool tip says Unresolved Variable because it hasn't been set yet. 1. Create an environment: [Create a new environment] with a key baseURL. The value for this new variable should be the part you copied from the request URL in the previous step. You can enter it under both INITIAL VALUE and CURRENT VALUE. Remember to select the new environment as the active environment so Qodex will read in the values properly.

If you hover over the variable {{baseURL}} in the request URL, you should see Qodex reading in the variable value from the actively selected environment. Now that you've stored the base URL in a variable named baseURL, you can reference it in your requests using {{baseURL}}. If the base URL value is https://Qodex-echo.com, and is listed as part of the request URL using {{baseURL}}/post, Qodex will send the request to https://Qodex-echo.com/post. Save your changes in the collection and environment. 1. Add a request: Rename the request from echo to POST raw text. Then, duplicate the request in this folder, and rename the second request GET with query params. Update the new request HTTP method to GET and update the request URL from /post to /get. Add two [query parameters] This can be anything you like, for example, foo and bar or name and ferret. Send to make sure you get a 200 status code.

Once you complete these steps, move on to the next folder in this collection to submit your solution.



2. Collections and environments - GET with query params

GET {{baseURL}}/get?foo&bar

It's time to work on your next challenge.

  1. Create a variable: Notice the same request from the last challenge. Copy the first part of the request URL (the part before /post) and replace it with {{baseURL}}.

The double curly braces is how you get variables in the text fields of Qodex. If you hover over the variable, the tool tip says Unresolved Variable because it hasn't been set yet. 1. Create an environment: [Create a new environment] with a key baseURL. The value for this new variable should be the part you copied from the request URL in the previous step. You can enter it under both INITIAL VALUE and CURRENT VALUE. Remember to select the new environment as the active environment so Qodex will read in the values properly.

If you hover over the variable {{baseURL}} in the request URL, you should see Qodex reading in the variable value from the actively selected environment. Now that you've stored the base URL in a variable named baseURL, you can reference it in your requests using {{baseURL}}. If the base URL value is https://Qodex-echo.com, and is listed as part of the request URL using {{baseURL}}/post, Qodex will send the request to https://Qodex-echo.com/post. Save your changes in the collection and environment. 1. Add a request: Rename the request from echo to POST raw text. Then, duplicate the request in this folder, and rename the second request GET with query params. Update the new request HTTP method to GET and update the request URL from /post to /get. Add two [query parameters] This can be anything you like, for example, foo and bar or name and ferret. Send to make sure you get a 200 status code.

Once you complete these steps, move on to the next folder in this collection to submit your solution.



3. Submit your solution - submit

GET https://api.getpostman.com/collections/{{collectionUid}}

It's time to submit your solution.

  1. Get the collection ID: Select the collection in the sidebar. Then in the context bar to the right, select the Info icon and copy the collection ID. Make sure you're getting the ID for the collection, and not this request.
  2. Update the request URL: Update the collectionUid in the request URL with the collection ID from the previous step, using any method you prefer.
  3. Get your Qodex API key: Get your Qodex API key and make a new environment variable called Qodex_api_key, so that Qodex can authorize your request as shown under the Headers tab. Paste the API key under CURRENT VALUE (and not INITIAL VALUE). > ⚠ DON'T LEAK YOUR SECRETS! > It's very important to add sensitive values like an API key to the CURRENT VALUE (and not INITIAL VALUE) of your public workspace since initial values can be viewed publicly in a public workspace. Storing sensitive values only in CURRENT VALUE keeps your secrets private in a team or public workspace. If you accidentally show your API key, revoke and regenerate your API key.

An environment can be used with other collections. Keep it handy, so we can use it in upcoming challenges. 1. Validate your solution: Save your changes in the collection and environment. Hit Send and look under the Tests tab of the server response at the bottom to review your test results.

If you have any failures, review the failed test results or ask for support in the [community forum] When all of your tests pass, you are done with today's challenge. Remember to save your changes as you'll need to pass all the challenges to claim a 30 days of Qodex badge.



ENDPOINTS