[Guide] How to Pass Boolean Values Using Postman?

While HTTP doesn't handle true booleans, Postman offers workarounds! Learn how to send boolean data in your requests using formats like JSON (true/false) or form-data (1/0), ensuring your server interprets them correctly. This guide explores both methods and covers common pitfalls to avoid.

Steven Ang Cheong Seng

Steven Ang Cheong Seng

15 May 2025

[Guide] How to Pass Boolean Values Using Postman?

Effective communication between APIs and client applications often relies on transmitting boolean data, representing true or false values. In the realm of API testing, tools like Postman empower developers to construct and transmit requests that accurately reflect real-world interactions. This guide delves into the specific methods for passing boolean values using Postman, ensuring that your API integrations function as intended.

💡
Apidog is an all-in-one API development platform complete with functionalities for the entire API lifecycle. If you are a developer who is planning to create complex APIs that will process various kinds of data types, Apidog is an excellent choice.

If you wish to learn more about Apidog, make sure to click the button below (Apidog is free to use!).
Apidog An integrated platform for API design, debugging, development, mock, and testing
REAL API Design-first Development Platform. Design. Debug. Test. Document. Mock. Build APIs Faster & Together.
button

What is Postman?

postman logo

Postman, a popular API development platform, empowers developers to streamline their workflow. It offers a comprehensive suite of functionalities encompassing building, testing, and documenting APIs. This versatility has made Postman a go-to tool for developers tackling any API-related challenge.

Postman API Platform

What are Boolean Values in APIs?

In the context of APIs, boolean values represent logical states with only two possibilities: true or false. These values are fundamental for conveying conditions, flags, and results within data exchanges. They allow APIs to communicate the success or failure of operations, indicate the presence or absence of data, and control the execution flow of logic based on specific conditions.

Where are Boolean Values Found?

Request Parameters

Response Data

Error Codes

Step-by-step Guide to Passing Boolean Values in Postman

Step 1 - Create a Postman Account

Create a new Postman account (only if you do not have one) and start downloading the Postman application onto your device. The application offers more features than its web version.

sign up for free postman account

Step 2 - Create a New API Request on Postman

create new request postman

Once you have installed Postman, create a new request by clicking the New button in the top left corner of the Postman window. Select HTTP Request to create a new request, as shown in the image above.

Step 3 - Enter API Method and Details

Next, you need to include the details of the API request you wish to create. It must include components such as the URL, HTTP methods, and additional parameters the API will require.

Step 4 - Open the Pre-Request Script Section

open pre request section postman

On your completed API, search for the Pre-request script section, as shown in the image above.

Step 5 - Insert Necessary Code For Including Boolean Values

In this empty section under the Pre-request Script tab, insert the following lines of code so that you can include a boolean value.

var bool = [true, false];
pm.globals.set('boolVal',  bool[Math.floor(Math.random()*bool.length)]);

"BoolVal": {{boolVal}},

Step 6 - Include it in the API Request's Parameter You Wish to Send

include boolean value in parameter postman

Make sure to include the boolean value in the parameter section, as shown in the image above.

Apidog - Create APIs without Limits or Restrictions

Apidog is a comprehensive API development platform like Postman. However, Apidog provides full functionalities for the entire API lifecycle - developers no longer need to download additional API tools.

apidog mock interface
Apidog An integrated platform for API design, debugging, development, mock, and testing
REAL API Design-first Development Platform. Design. Debug. Test. Document. Mock. Build APIs Faster & Together.
button

Create APIs from Scratch with Apidog

Apidog equips developers with all the necessary tools for creating APIs. All the user needs to prepare are the ideas on what the API should be.

new api apidog

To begin, press the New API button, as shown in the image above.

add details new api apidog

Next, you can select many of the API's characteristics. On this page, you can:

Freely Choose Parameter Data Types with Apidog

With Apidog, you do not need to put additional code to enable boolean values. Apidog is capable of facilitating boolean values to be sent in an API request.

apidog select data type

With Apidog, you can choose from virtually any data type that exists!

Conclusion

By understanding the different methods for passing boolean values in Postman (JSON and form-data), you can effectively construct requests that accurately reflect your desired API interactions. Remember to always consult the API documentation to verify the expected data format and boolean representation (true/false or 1/0) to ensure seamless communication.

With this knowledge, you'll be well-equipped to leverage Postman for efficient and reliable API testing, ensuring your integrations function as intended.

Explore more

Apidog SEO Settings Explained: Maximize Your API Docs Visibility

Apidog SEO Settings Explained: Maximize Your API Docs Visibility

Discover how to supercharge your API documentation's visibility with Apidog's powerful SEO features. This comprehensive guide covers everything from page-level optimizations like custom URLs and meta tags to site-wide settings such as sitemaps and robots.txt.

18 June 2025

How to Protect API Specification from Unauthorized Users with Apidog

How to Protect API Specification from Unauthorized Users with Apidog

Learn how Apidog empowers you to protect API specification from unauthorized users. Explore advanced API documentation security, access controls, and sharing options for secure API development.

17 June 2025

How to Use the PostHog MCP Server?

How to Use the PostHog MCP Server?

Discover how to use the PostHog MCP server with this in-depth technical guide. Learn to install, configure, and optimize the server for seamless PostHog analytics integration using natural language. Includes practical use cases and troubleshooting.

16 June 2025

Practice API Design-first in Apidog

Discover an easier way to build and use APIs