DEV Community

Talha Aamir
Talha Aamir

Posted on

Postman: how to send api requests w/t json objects

Postman is, at this point probably, the tool used to run and test application endpoints. As you might imagine, especially for working on in-progress or already developed feature even, it is faster and convenient to quickly test your endpoints instead of manually running a flow and waiting to see if an endpoint returns fine.

I needed to go back to using postman for an in-progress feature and thought it would be nice to have this article for future reference for myself and for anyone else. Especially, since this took me a few mins to properly set up.

Installation

I'm using Ubuntu, so I just used the snap store to install:
sudo snap install postman

Objectives

The request I want to test

  • is a POST request
  • uses authentication
  • uses a json object, to pass data

Usage

This section will have a few screens for clarity and so its easier, and maybe faster to skim through

  1. Set your request type and fill in your endpoint url Endpoint url and request setup
  2. Since the endpoint has authentication, you can navigate to the authorization section, and select and set your corresponding authorization token/credentials. For me its a basic authentication token. Authentication Token
  3. Finally, since we have a json object, it is supposed to be passed in the body tab. I am using test data to demonstrate how to go about doing it. Since we are sending json data, I switched the input type to raw, which allows us to write raw text, and changed the type from text to json, just so postman gives us some nice highlighting Json Object Filling Once done we can save, and run the endpoint, and it will return data, or an error in case it fails.

Top comments (0)