How to Add a Header to a curl Request

Date:

Share post:

curl is one of those great utilities that’s been around seemingly forever and has endless use cases. These days I find myself using curl to batch download files and test APIs. Sometimes my testing leads me to using different HTTP headers in my requests.

To add a header to a curl request, use the -H flag:

curl -X 'GET' \
 'https://nft.api.cx.metamask.io/collections?chainId=1' \
 -H 'accept: application/json' \
 -H 'Version: 1'

You can add multiple headers with multiple -H uses. Header format is usually [key]: [value].

Request Metrics real user monitoring
Request Metrics real user monitoring
Request Metrics real user monitoring
  • 5 More HTML5 APIs You Didn’t Know Existed

    5 More HTML5 APIs You Didn’t Know Existed

    The HTML5 revolution has provided us some awesome JavaScript and HTML APIs.  Some are APIs we knew we’ve needed for years, others are cutting edge mobile and desktop helpers.  Regardless of API strength or purpose, anything to help us better do our job is a…

  • Convert XML to JSON with JavaScript
  • Chris Coyier’s Favorite CodePen Demos II

    Chris Coyier’s Favorite CodePen Demos II

    Hey everyone! Before we get started, I just want to say it’s damn hard to pick this few favorites on CodePen. Not because, as a co-founder of CodePen, I feel like a dad picking which kid he likes best (RUDE). But because there is just so…

  • Using MooTools to Instruct Google Analytics to Track Outbound Links

    Using MooTools to Instruct Google Analytics to Track Outbound Links

    Google Analytics provides a wealth of information about who’s coming to your website. One of the most important statistics the service provides is the referrer statistic — you’ve gotta know who’s sending people to your website, right? What about where you send others though?


Source link
spot_img

Related articles

20 Years Ago, ‘GUN’ Brought America’s Old West (And An All-Star Cast) To GameCube

Ever feel like getting your video game cowboy on, but Red Dead Redemption and its kinda bloated sequel,...

In memoriam: David Harley

Former colleagues and friends remember the...

What Is Causing The Industry CPU shortage?

Intel did pretty well this last quarter but two things they said in the last quarterly call stuck...