Questions tagged [curl]

cURL is a library and command-line tool for transferring data using various protocols such as HTTP, FTP and SFTP. The cURL project produces two products, libcurl and curl. This tag covers all usages of cURL, regardless of which cURL product is used.

The cURL project consists of a command-line tool, curl, and a C library, libcurl, for transferring data using internet protocols such as DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, SSH, Telnet and TFTP

For example, curl can be used to download a web page and save it to a file:

curl -o curltest.html www.example.com

, written in , has bindings for a number of languages. Please use the tag for questions about compiling or integrating cURL into another project (i.e. compiling with cURL support).

is an example of a project that has implemented cURL and its use has become quite popular, due to its versatility.

Common PHP Questions

Resources

43780 questions
415
votes
9 answers

POST XML file using cURL command line

How can I POST an XML file to a local server http://localhost:8080 using cURL from the command line? What command should I use?
Arnab Sen Gupta
  • 5,639
  • 5
  • 24
  • 17
397
votes
16 answers

Can PHP cURL retrieve response headers AND body in a single request?

Is there any way to get both headers and body for a cURL request using PHP? I found that this option: curl_setopt($ch, CURLOPT_HEADER, true); is going to return the body plus headers, but then I need to parse it to get the body. Is there any way to…
gremo
  • 47,186
  • 75
  • 257
  • 421
395
votes
23 answers

List all indexes on ElasticSearch server?

I would like to list all indexes present on an ElasticSearch server. I tried this: curl -XGET localhost:9200/ but it just gives me this: { "ok" : true, "status" : 200, "name" : "El Aguila", "version" : { "number" : "0.19.3", …
Eva
  • 4,859
  • 3
  • 20
  • 26
387
votes
5 answers

Passing a URL with brackets to curl

If I try to pass a URL to curl that contains brackets, it fails with an error: $ curl 'http://www.google.com/?TEST[]=1' curl: (3) [globbing] illegal character in range specification at pos 29 However, if I escape both brackets, it appears to…
chaimp
  • 16,897
  • 16
  • 53
  • 86
386
votes
12 answers

Simulate a specific CURL in PostMan

I am using Postman to test some Curl requests to an API server. The API developers gave us the curl command, but I can't send it from the Postman. How to make such a request from the Postman? curl -X POST…
Marin Bînzari
  • 5,208
  • 2
  • 26
  • 43
383
votes
6 answers

Send request to cURL with post data sourced from a file

I need to make a POST request via cURL from the command line. Data for this request is located in a file. I know that via PUT this could be done with the --upload-file option. curl host:port/post-file -H "Content-Type: text/xml" --data…
user253202
373
votes
3 answers

How to define the basic HTTP authentication using cURL correctly?

I'm learning Apigility (Apigility docu -> REST Service Tutorial) and trying to send a POST request with basic authentication via cURL: $ curl -X POST -i -H "Content-Type: application/hal+json" -H "Authorization: Basic YXBpdXNlcjphcGlwd2Q="…
automatix
  • 14,018
  • 26
  • 105
  • 230
370
votes
12 answers

Display curl output in readable JSON format in Unix shell script

In my Unix shell script, when I execute a curl command, the result will be displayed as below which I am redirecting to…
Jams
  • 3,769
  • 3
  • 18
  • 13
370
votes
7 answers

How to count items in JSON object using command line?

I'm getting this kind of JSON reply from a curl command: [ { "cid": 49, "pyn": "yi4", "hans": "亿", "hant": "億", "tid": 68, "l10n": "cent million", "pid": 1, "pos": "num", "pos_txt": "" }, { "cid": 50, …
Édouard Lopez
  • 40,270
  • 28
  • 126
  • 178
352
votes
23 answers

Curl to return http status code along with the response

I use curl to get http headers to find http status code and also return response. I get the http headers with the command curl -I http://localhost To get the response, I use the command curl http://localhost As soon as use the -I flag, I get only…
randominstanceOfLivingThing
  • 16,873
  • 13
  • 49
  • 72
352
votes
5 answers

Automatically add newline at end of curl response body

If the HTTP response body for a curl request doesn't contain a trailing newline, I end up with this really annoying condition where the shell prompt is in the middle of the line, and escaping is messed up enough that when I put the last curl command…
Kevin Burke
  • 61,194
  • 76
  • 188
  • 305
339
votes
23 answers

cURL error 60: SSL certificate: unable to get local issuer certificate

I am trying to send an API request using Stripe but get the error message: cURL error 60: SSL certificate problem: unable to get local issuer certificate This is the code I am running: public function chargeStripe() { $stripe = new Stripe; …
LoveAndHappiness
  • 9,735
  • 21
  • 72
  • 106
317
votes
4 answers

How to send file contents as body entity using cURL

I am using cURL command line utility to send HTTP POST to a web service. I want to include a file's contents as the body entity of the POST. I have tried using -d as well as other variants with type info like --data…
Roy Hinkley
  • 10,111
  • 21
  • 80
  • 120
316
votes
10 answers

curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number

When I try to connect to any server (e.g. google.com) using curl (or libcurl) I get the error message: curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number Verbose output: $ curl www.google.com --verbose * Rebuilt URL to:…
Bernhard Jaeger
  • 3,373
  • 2
  • 10
  • 18
310
votes
9 answers

Save file to specific folder with curl command

In a shell script, I want to download a file from some URL and save it to a specific folder. What is the specific CLI flag I should use to download files to a specific folder with the curl command, or how else do I get that result?
Ziyaddin Sadigov
  • 8,893
  • 13
  • 34
  • 41