# Curl single quotes vs. double quotes

**URL:** <https://discuss.elastic.co/t/curl-single-quotes-vs-double-quotes/114671>\
**Category:** Elasticsearch\
**Created:** [January 9, 2018, 9:42am UTC](https://discuss.elastic.co/t/curl-single-quotes-vs-double-quotes/114671 "2018-01-09T09:42:53Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![boudewijnk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/boudewijnk/32/26426_2.png) [@boudewijnk](https://discuss.elastic.co/u/boudewijnk)\
**Post date:** [January 9, 2018, 9:42am UTC](https://discuss.elastic.co/t/curl-single-quotes-vs-double-quotes/114671/1 "2018-01-09T09:42:53Z")

</div>

I follow the [Elastic tutorial](https://www.elastic.co/guide/en/elasticsearch/reference/current/_exploring_your_data.html) and experience and error when I use the curl code provided in the tutorial:

```
curl -H "Content-Type: application/json" -XPOST 'localhost:9200/bank/account/_bulk?pretty&refresh' --data-binary "@accounts.json"

```

When I replace the single quotation marks with double quotation marks it works fine.

The problem not only occurs with the above command but everytime I use single quotation marks in curl. Am I the only one experiencing issues with the single quotation marks?

Another example. This doesn't work:

```
curl -XGET 'localhost:9200/_cat/health?v&pretty'

```

This works fine:

```
curl -XGET "localhost:9200/_cat/health?v&pretty"
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 9, 2018, 3:18pm UTC](https://discuss.elastic.co/t/curl-single-quotes-vs-double-quotes/114671/2 "2018-01-09T15:18:08Z")

</div>

On? Windows? Linux?

Anyway, it's always better using Kibana dev console. Much easier.

---

<div class="post-metadata">

**Author:** ![arisbanach](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@arisbanach](https://discuss.elastic.co/u/arisbanach)\
**Post date:** [January 9, 2018, 3:37pm UTC](https://discuss.elastic.co/t/curl-single-quotes-vs-double-quotes/114671/3 "2018-01-09T15:37:04Z")

</div>

I think this is because of the special ampersand character. It needs to be surrounded with double quotes because of its encoding.

You can also use CURL's `-d` option to specify parameters instead.

---

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [January 9, 2018, 3:38pm UTC](https://discuss.elastic.co/t/curl-single-quotes-vs-double-quotes/114671/4 "2018-01-09T15:38:52Z")

</div>

Both work well on Linux, so @boudewijnk is probably on Windows

---

<div class="post-metadata">

**Author:** ![boudewijnk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/boudewijnk/32/26426_2.png) [@boudewijnk](https://discuss.elastic.co/u/boudewijnk)\
**Post date:** [January 9, 2018, 4:32pm UTC](https://discuss.elastic.co/t/curl-single-quotes-vs-double-quotes/114671/5 "2018-01-09T16:32:30Z")

</div>

I use Windows indeed.

I know I can get it running with double quotes. However, it's just a matter of convenience. I can easily copy the curl code from the tutorial, but when I need to replace the single quotes everytime, that's not that quick anymore.

---

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [January 9, 2018, 4:35pm UTC](https://discuss.elastic.co/t/curl-single-quotes-vs-double-quotes/114671/6 "2018-01-09T16:35:03Z")

</div>

Do you have any way to use [PowerShell](https://docs.microsoft.com/en-us/powershell/scripting/getting-started/fundamental/using-windows-powershell?view=powershell-5.1) which accepts both single and double quotes?

---

<div class="post-metadata">

**Author:** ![boudewijnk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/boudewijnk/32/26426_2.png) [@boudewijnk](https://discuss.elastic.co/u/boudewijnk)\
**Post date:** [January 9, 2018, 4:55pm UTC](https://discuss.elastic.co/t/curl-single-quotes-vs-double-quotes/114671/7 "2018-01-09T16:55:15Z")

</div>

I do have access to PowerShell.

However, using the command from my first message gives this response:

```
    PS C:\Users\Admin> curl -H "Content-Type: application/json" -XPOST 'http://localhost:9200/bank/account/_bulk?pr
etty&refresh' --data-binary "@accounts.json"
Invoke-WebRequest : Cannot bind parameter 'Headers'. Cannot convert the "Content-Type: application/json"
value of type "System.String" to type "System.Collections.IDictionary".
At line:1 char:9
+ curl -H "Content-Type: application/json" -XPOST 'http://localhost:920 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.InvokeWebRequestCo
   mmand
```

---

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [January 9, 2018, 4:59pm UTC](https://discuss.elastic.co/t/curl-single-quotes-vs-double-quotes/114671/8 "2018-01-09T16:59:52Z")

</div>

As @dadoonet mentioned, you're better off going through Kibana when working on Windows machines 🙂

---

<div class="post-metadata">

**Author:** ![boudewijnk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/boudewijnk/32/26426_2.png) [@boudewijnk](https://discuss.elastic.co/u/boudewijnk)\
**Post date:** [January 10, 2018, 4:05pm UTC](https://discuss.elastic.co/t/curl-single-quotes-vs-double-quotes/114671/9 "2018-01-10T16:05:00Z")

</div>

I was actually using kibana for most parts of the tutorial, but I couldn't figure out how to load the json data with kibana

---

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [January 10, 2018, 4:08pm UTC](https://discuss.elastic.co/t/curl-single-quotes-vs-double-quotes/114671/10 "2018-01-10T16:08:33Z")

</div>

In Kibana you can very well do a bulk call by copying the content of the accounts.json file

```
POST _bulk
...content of accounts.json goes here...
```

---

<div class="post-metadata">

**Author:** ![boudewijnk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/boudewijnk/32/26426_2.png) [@boudewijnk](https://discuss.elastic.co/u/boudewijnk)\
**Post date:** [January 10, 2018, 4:49pm UTC](https://discuss.elastic.co/t/curl-single-quotes-vs-double-quotes/114671/11 "2018-01-10T16:49:43Z")

</div>

Thanks Val.

```
POST /bank/account/_bulk
...json content here...

```

Works indeed and is much faster than loading with curl (which takes a few minutes in which I cannot properly operate my machine)

---

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [January 10, 2018, 4:50pm UTC](https://discuss.elastic.co/t/curl-single-quotes-vs-double-quotes/114671/12 "2018-01-10T16:50:34Z")

</div>

Glad it helped!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 7, 2018, 4:50pm UTC](https://discuss.elastic.co/t/curl-single-quotes-vs-double-quotes/114671/13 "2018-02-07T16:50:50Z")

</div>

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