cURL - Could not get simple GET to work

Sorry this could be a basic question as I'm getting started.

I'm performing a simple match all type query via Kibana which just works fine.

Then I just did "Copy as cURL" from kibana which looks likes this -

curl -XGET "http://localhost:9200/car/default/_search" -H 'Content-Type: application/json' -d'
{"query": {"match_all": {}}}'

and paste it as-is onto my Windows - Powershell but see this error -

PS C:\Users\aravind> curl -XGET "http://localhost:9200/car/default/_search" -H 'Content-Type: applica
tion/json' -d'
{"error":{"root_cause":[{"type":"json_parse_exception","reason":"Unexpected character (''' (code 39)): expected a valid
value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.elasticsearch.transport.netty4.ByteBu
fStreamInput@40fb2941; line: 1, column: 2]"}],"type":"json_parse_exception","reason":"Unexpected character (''' (code 39
)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.elasticsearch.tr
ansport.netty4.ByteBufStreamInput@40fb2941; line: 1, column: 2]"},"status":500}PS C:\Users\aravind> {"query": {"ma
tch_all": {}}}'
Unexpected token ':' in expression or statement.
At line:1 char:10
"+ {"query": <<<< {"match_all": {}}}'
+ CategoryInfo : ParserError: (::String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken"

Now when I formatted the cURL like below (provided space between -d and single quote and then also moved the search query portion into first line essentially making the entire command into single line)

curl -XGET "http://localhost:9200/car/default/_search" -H 'Content-Type: applica
tion/json' -d '{"query": {"match_all": {}}}'

but I get this error -

{"error":{"root_cause":[{"type":"json_parse_exception","reason":"Unexpected character ('q' (code 113)): was expecting do
uble-quote to start field name\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@54a03843; line: 1, co
lumn: 3]"}],"type":"json_parse_exception","reason":"Unexpected character ('q' (code 113)): was expecting double-quote to
start field name\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@54a03843; line: 1, column: 3]"},"s
tatus":500}PS C:\Users\aravind>

What am I missing ?

This post may help: Curl single quotes vs. double quotes

Thanks ... Seems like this is hard-time with Windows.

Atleast I'm trying to see how to get this working on Postman. I can get every other thing working than this search on post man. How should I specify

{"query": {"match_all": {}}}'

in Postman

or even this one

{"query": {"match": { "name" : "Honda" }}}

You should better use Kibana and its developer Console. Much easier.

Sure, thanks

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.