Guys, please, spare my sanity. I'm trying to run a curl command with atlassian/ssh-run:0.8.1 as follows to no avail:
curl --request POST --url https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE/purge_cache --header "Content-Type: application/json" --header "X-Auth-Key: $CLOUDFLARE_APIKEY" --header "X-Auth-Email: $CLOUDFLARE_EMAIL" --data "{"purge_everything": true}"
The request fails with the message from the endpoint saying that "Request must contain one of "purge_everything". Obviously, it has to do something with escaping the quotes in the JSON that is being sent.
I tried it all: backslashes, single quotes, double and tripple single and double quotes — nothing seems to work.
Please, tell me how to send JSON with curl through atlassian/ssh-run:0.8.1
I think it's most legible if you quote it like this:
--data '{"purge_everything": true}'
Although it's not relevant to this example, I like to programmatically generate JSON documents using "jq" in a shell, or the "json" library in Python. They do the various required quoting and escaping correctly so I don't have to worry about it, particularly for user-provided inputs.
While it is legible indeed it does not work when run as a command in atlassian/ssh-run:0.8.1
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you please be more specific? You're calling "Purge Cached Content" from the CloudFlare API, yes?
If it's the same response from CloudFlare, does it work with other clients like Python or Postman?
Your original request:
--data "{"purge_everything": true}"
...failed because the shell interpreted the data parameter as "{"
Single quotes interpret the entire string as one parameter (at the expense of variable expansion, which you aren't using).
The double-quote alternative would be escaping the double quotes in the JSON document like this:
--data "{\"purge_everything\": true}"
...which I believe is less expressive of your intent than the single-quoted version.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.