Menu

1 / 4

How to Add a Header to a curl Request

#davidwalsh#curl#using#element#sometimes
Long article (300 words) — no AI summary yet.
Reading 0:00
15s threshold

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] .

Recent Features

Regular Expressions for the Rest of Us

Sooner or later you'll run across a regular expression. With their cryptic syntax, confusing documentation and massive learning curve, most developers settle for copying and pasting them from StackOverflow and hoping they work. But what if you could decode regular expressions and harness their power? In...

39 Shirts – Leaving Mozilla

In 2001 I had just graduated from a small town high school and headed off to a small town college.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.