Skip to content

aasliturkoglu/trello-rest-api-postman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 

Repository files navigation

📋 trello-rest-api-postman

This project demonstrates how to create boards, lists, card, checklist, and label using the Trello API via Postman.

📑 Content

📋 Requirements

🔑 Getting API Key and Token

  1. Create an Account on Trello

  2. Create a Workspace on Trello

  3. Activate the Power-Up

  4. Click the New button in the upper right corner

  5. Fill in the new power-up field and select workspace then click the Create button

  6. Click the Generate a new API Key button

  7. Then API Key is created and final step click the Token button

⚙️ Postman Setting Environment and Global Variables

  1. Create a Collection on Trello
  1. Create a Collection on Trello

  2. Click the Variables in this Request button in the upper right corner

  1. Click the Enviroment button
  1. Give names for key and token and enter the token and key values
  1. Repeat step 3.

  2. Click the Globals

  3. Add the baseURL portion of the url from the REST API documentation.

For example, in this URL, https://api.trello.com/1/actions/{id}?key=APIKey&token=APIToken ---> the BaseURL is https://api.trello.com/

🌐 🔗 API Operations

1️⃣ Create a Board

  1. Open the Trello Rest API Documentation
  2. Copy the URL in the Trello Rest API Documentation
  3. Go to Postman
  4. Create a new request and give a name (Create a Board). The method type for this operation is POST. Choose POST. Paste the URL and Convert the BaseURL part of URL to the global variable we created for BaseURL. Use enviroment variables we created for API Key and Token. Then give a name for new board.
  1. Write test to check the response status code.
  1. Send the request. Response status code should be 200.
  2. Check the Trello.

2️⃣ Create a new List

  1. Open the Trello Rest API Documentation
  2. Copy the URL in the Trello Rest API Documentation
  3. Go to Postman. Create a new request and give a name (Create a new List). The method type for this operation is POST. Choose POST. Paste the URL and Convert the BaseURL part of URL to the global variable we created for BaseURL. Use enviroment variables we created for API Key and Token.
  4. Give a name for new list.
  5. To determine which board to add the list to, copy the id of the board we created in the previous step and paste it into the value field opposite the idBoard parameter.
  6. Write test to check the response status code. Send the request. Response status code should be 200.
  1. Check the Trello.

3️⃣ Create a new Card

  1. Open the Trello Rest API Documentation
  2. Copy the URL in the Trello Rest API Documentation
  3. Go to Postman. Create a new request and give a name (Create a new Card). The method type for this operation is POST method. Choose POST method. Paste the URL and Convert the BaseURL part of URL to the global variable we created for BaseURL. Use enviroment variables we created for API Key and Token.
  4. Paste "&name=" to end of the URL. This will create the name parameter.
  5. Give a name for new card.
  6. To determine which list to add the card to, copy the id of the list we created in the previous step and paste it into the value field opposite the idList parameter.
  7. Write test to check the response status code. Send the request. Response status code should be 200.
  1. Check the Trello.

4️⃣ Create a Checklist

  1. Open the Trello Rest API Documentation
  2. Copy the URL in the Trello Rest API Documentation
  3. Go to Postman. Create a new request and give a name (Create a Checklist). The method type for this operation is POST method. Choose POST method. Paste the URL and Convert the BaseURL part of URL to the global variable we created for BaseURL. Use enviroment variables we created for API Key and Token.
  4. Paste "&name=" to end of the URL. This will create the name parameter.
  5. Give a name for checklist.
  6. To determine which card to add the checklist to, copy the id of the card we created in the previous step and paste it into the value field opposite the idCard parameter.
  7. Write test to check the response status code. Send the request. Response status code should be 200.
  1. Check the Trello.

5️⃣ Create a Label

  1. Open the Trello Rest API Documentation
  2. Copy the URL in the Trello Rest API Documentation
  3. Go to Postman. Create a new request and give a name (Create a Label). The method type for this operation is POST. Choose POST method. Paste the URL and Convert the BaseURL part of URL to the global variable we created for BaseURL. Use enviroment variables we created for API Key and Token.
  4. Give a name for label and choose a color from among the valid colors. Valid values: yellow, purple, blue, red, green, orange, black, sky, pink, lime for color parameter.
  5. To determine which board to add the label to, copy the id of the board we created in the first step and paste it into the value field opposite the idBoard parameter.
  6. Write test to check the response status code. Send the request. Response status code should be 200.
  1. Check the Trello.

▶️ Collection Runner

  1. Click the name of the collection. Then click the Runs button.
  1. Click the Run Project button.
  1. View the Result
  1. View the Summary

🔁 Dynamic Variables

By storing values returned from the API—such as id or name—in a variable, we can reuse them in subsequent requests. This eliminates the need for manual copy-paste and allows Postman to automatically pass data from one response to the next request. As a result, dependent operations can be executed in a seamless, chained, and dynamic workflow.

  1. Saving the ID in the Post-request Script Firstly, In the Tests (Post-request Script) section, we extract the response body and store a specific value (such as an ID) in an environment variable: let response = pm.response.json(); pm.environment.set("idboard", response.id);

The idboard variable we set here will be automatically created and stored in the Environments section. This allows Postman to reuse it in other requests without any manual input.

  1. Using the idboard Variable in Create a List Request

Apply the same process we used in the previous step to save the list ID. After creating the list, extract the response and store the returned id value as an environment variable (e.g., idlist). This will allow us to reuse the list ID in the following requests just like we did with idboard.

You can apply these steps to all operations in the project. By saving each returned ID (board, list, card, checklist, label) as an environment variable, you can easily reuse them in subsequent requests and create fully connected, automated API workflows.

Using the Collection Runner, you can run the project multiple times in succession without errors. Since all IDs are dynamically stored and reused via environment variables, the requests remain fully connected and automated, allowing for seamless repeated execution.

📝 Pre-request Scripts

Pre-request scripts are executed before sending an API request. They allow us to:

  • Set or update environment and global variables dynamically

  • Generate timestamps, tokens, or random data required for the request

  • Prepare any data or configuration needed for the request to run successfully

Essentially, they let us automate setup tasks so that each request has the correct data and context before execution.

  1. pm.environment.set("nameBoard", "udemy " + parseInt(Math.random()*1000)); in the Pre-request field for nameBoard
  1. Use this nameBoard variable in the request
  1. Write a Test and Check

let response = pm.response.json(); // we wrote this already pm.test("response name is equal to expected name", function () { pm.expect(response.name).is.eql(pm.environment.get("nameBoard")); console.log("response name: ", response.name); console.log("expected name: ", pm.environment.get("nameBoard"));

});

About

Practices for the post method with Trello and Postman

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published