user3893836
user3893836

Reputation: 85

CURL GET escaping double quote

I am trying to sending GET request to retrieve JSON result.

This one worked prefectly for me:

curl -i -H "Accept: */*" -X GET 'http://10.50.227.58:30000/api/v1/query?query=sum(container_memory_working_set_bytes)by(container_name,pod_name)&start=1598860800&end=1598860859';echo

However, what I need is below, and no matter how it failed with whatever I tried(for example, ", using %22) etc..

curl -i -H "Accept: */*" -X GET 'http://10.50.227.58:30000/api/v1/query?query=sum(container_memory_working_set_bytes{container_name!="POD"})by(container_name,pod_name)&start=1598860800&end=1598860859';echo

Can anyone help me?

Thanks a lot in advance.

Upvotes: 2

Views: 1798

Answers (2)

user969068
user969068

Reputation: 2943

You have to encode URL with --data-urlencode

curl -G -X GET \
       --data-urlencode 'query=sum(container_memory_working_set_bytes{container_name!="POD"})by(container_name,pod_name)' \
       --data-urlencode 'start=1598860800' \
       --data-urlencode 'end=1598860859' \
       http://10.50.227.58:30000/api/v1/query

Upvotes: 5

Telinov Dmitri
Telinov Dmitri

Reputation: 441

Try:

\"

or

'\"'

Example:

$ echo 'hello'\"'world'
hello"world

Or first escape with double quotes and then inside with single quotes

Upvotes: 0

Related Questions