How-To: Executing Queries from Powershell and Bash

When using curl from the command line to execute queries you should be aware of the requirement to escape quotes within the queries.

For example, within bash or zsh you can use:

shell
$ curl -X POST \
     -H 'Authorization: Bearer $TOKEN' \
 -H 'Content-Type: application/json' \
 -H 'Accept: application/x-ndjson' \
 "https://$YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/query" \
 -d '{"queryString": "", "start": "10s", "isLive": true}'

Within Powershell, the quotes must be explicitly escaped:

powershell
PS\> curl.exe -X POST \
     -H 'Authorization: Bearer $TOKEN' \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/x-ndjson' \
     "https://$YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/query" \
     -d '{\"queryString\": \"\", \"start\": \"10s\", \"isLive\": true}'

The quotes must be escaped so that they are passed on correctly with the payload.