Passing a URL with brackets to curl
Never mind, I found it in the docs:
-g/--globoff
This option switches off the "URL globbing parser". When you set this option, you can
specify URLs that contain the letters {}[] without having them being interpreted by curl
itself. Note that these letters are not normal legal URL contents but they should be
encoded according to the URI standard.
Globbing uses brackets, hence the need to escape them with a slash \
. Alternatively, the following command-line switch will disable globbing:
--globoff
(or the short-option version: -g
)
Ex:
curl --globoff https://www.google.com?test[]=1
None of the above answers worked for me, I have to replace all opening/closing brackets with %5B
and %5D
.
[ ---> %5B
and for
] ---> %5D
My initial curl url was like this this
https://test.com/computer/agent1/api/json?pretty=true&tree=executors[currentExecutable[url]]
Now I am using like this
https://test.com/computer/agent1/api/json?pretty=true&tree=executors%5BcurrentExecutable%5Burl%5D%5D