⚠️ This lesson is retired and might contain outdated information.

Set Custom Headers on an API Request in Postman

Colby Fayock
InstructorColby Fayock
Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 2 years ago

In this lesson, you'll learn how to add custom headers to an API request in Postman. We'll walk through finding automatically applied headers that are added to requests by default and how you can configure your own headers for custom requests.

Colby Fayock: [0:00] We're going to start off with a new request in Postman, where we're posting to an endpoint called post, the data test equals true. We can see this working, and if we hit Send, we can see that the status is 200, which is OK.

[0:10] Because on the code we're console.logging out parts of the event including the Path, HTTP Method, Body, and Headers, we can see in the terminal that we can see the Path as /post, the Method as POST, the Body of test equals true, and we also see all the default Headers that are set in Postman.

[0:25] If we wanted to modify the headers or simply see what's being sent, we can click the Headers tab inside of Postman. Currently, we don't see any headers there, but if we click hidden, we can see all the ones that are automatically generated and included with Postman.

[0:36] Because we're setting our body with the type of JSON, it automatically includes Content-Type of application/json, and because we're sending this from Postman, it also includes a User-Agent of PostmanRuntime.

[0:46] If we wanted to add our own custom headers, we can use this Headers table and add a Key-Value pair, so if I wanted to add a key of test and a value of true, I can now send my request, and I can now see that inside of my Event Headers, I have test equals true.

[0:59] When we add authorization through the Authorization tab, we can see that it's added as a hidden header, but if we wanted to do that manually, we can turn that off or we can add the authorization header and then set our value which we can then post and see that it gets sent with our request.

[1:12] In review, we had a POST Request where we wanted to send custom headers. We were able to see all the headers that were hidden that are generated by Postman itself. We can also see that we can set our own custom headers using the Headers table.

[1:22] When we send our request with those custom headers, we can see right in the event logs our custom header.

egghead
egghead
~ 2 hours ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today