Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cURL for Windows: how can I send multiple line command in a console?

Tags:

I am learning to use cURL and I need to run this in a console:

curl -XGET localhost:9200/library/book/_search?pretty=true -d {     "query" : {         "query_string" : { "query" : "title:crime" }     } } 

But this is a multi-line command. How can I handle it to send a complete command?

Note that I understand I can put the content after -d in a file to run this command.

like image 556
curious1 Avatar asked Jul 03 '14 14:07

curious1


People also ask

How do I run multiple curl commands in Windows?

The solution to this is to use the xargs command as shown alongside the curl command. The -P flag denotes the number of requests in parallel. The section <(printf '%s\n' {1.. 10}) prints out the numbers 1 – 10 and causes the curl command to run 10 times with 5 requests running in parallel.

How do I use the curl command in Windows?

Invoke curl.exe from a command window (in Windows, click Start > Run and then enter "cmd" in the Run dialog box). You can enter curl --help to see a list of cURL commands.


1 Answers

Sometime I have to use windows, try something like this :

curl -XPOST http://localhost:9200/_search -d^ "{^     \"query\": {^         \"query_string\": {^             \"query\": \"year:2003\"^         }^     }^ }" 

^ to extend a command to next line and
\" to escape " on the json

like image 129
Patrick Champion Avatar answered Oct 19 '22 01:10

Patrick Champion