Postman POST JSON: How to send JSON data to an API endpoint


In this tutorial you will learn how to make a Postman POST JSON request which essentially means to send a JSON body to your API endpoint.

In the previous video in the Junior Developer ‘How To Use Postman’ series you learnt how to create a POST request and send form data as if from a HTML web form.

(If you missed that video you can see it here: )

However sometimes a Postman POST JSON request is required as your API endpoint might not accept form-like data.

In fact it’s quite common for JavaScript based web applications (that use Node as the backend for example) to be setup to send AND receive all of their data in JSON format.

In the tutorial i’ll use a very basic PHP script to accept the JSON data, checking if a valid Postman POST JSON request is actually sent and returning an internal server error if not.

The Content-Type header is the key here as that is what will notify the PHP script that the data that is being sent is actually going to be in JSON format.

You will see that Postman actually sets the header for Content-Type automatically when you set the body of your request to JSON format. Of course you can manually set the Content-Type header yourself and check that it has been configured correctly in the Headers tab within Postman.

It is of course possible to send an empty body to the endpoint and still not produce an error but a more real-world application may have more in-depth data validation and error handling to prevent an empty body from being sent.

Related videos in the series:-
Postman GET Requests:
Postman POST Request:

(Visited 100 times, 1 visits today)