3.6 C
New York
Friday, November 22, 2024

How to add a header to a curl request


curl It’s one of those great utilities that has been around forever and has endless use cases. These days I find myself wearing curl to download files in batches and testing APIs. Sometimes my testing leads me to use 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. The header format is usually (key): (value).

  • Search API

    One of the worst kept secrets about AJAX on the web is that the underlying API, XMLHttpRequestIt wasn’t really built for what we’ve been using it for. We’ve done well in building elegant APIs around XHR, but we know we can do better. Our effort to…

  • JavaScript Promise API

    While synchronous code is easier to follow and debug, asynchronous code is generally better for performance and flexibility. Why “delay the show” when you can fire off numerous requests at once and then handle them when each is ready? Promises are becoming an important part of the JavaScript world…

  • MooTools Autocomplete Plugin
  • Save web form content using Control + S

    We’ve all used word processing applications like Microsoft Word, and if there’s one thing they’ve taught us, it’s to save every few seconds to prevent the inevitable crash. WordPress has mimicked this functionality within its WYSIWYG editor, and I use it myself…


Related Articles

Latest Articles