Reputation: 449
I get an error for this CURL command, whereas same works on Chrome DHC App. What am I missing here
[root@host125]# curl -sk -X 'GET' -H 'X-Auth-Token: [REDACTED]' -H 'Content-type: application/json' https://10.1.1.132/rest/rm-central/v1/recovery-sets?query="volumeType EQ 'vvol'"
{"badRequest": {"message": "QueryFilter Error :: Given Query Filter syntax 'query=' is not valid ", "code": 400}}
[root@host125]#
[root@host125]#
[root@host125]#
Upvotes: 15
Views: 89662
Reputation: 6515
Use the --data-urlencode
option of curl.
var=volumeType EQ 'vvol'
curl -sSLG "https://10.1.1.132/rest/rm-central/v1/recovery-sets" --data-urlencode "query=$var"
Note the manpage indicates this is for POST requests:
--data-urlencode
(HTTP) This posts data, similar to the other -d, --data options with the exception that this performs URL-encoding.
-G
or --get
allows it to be used in a GET request:
When used, this option will make all data specified with -d, --data, --data-binary or --data-urlencode to be used in an HTTP GET request instead of the POST request that otherwise would be used. The data will be appended to the URL with a '?' separator.
Upvotes: 5
Reputation: 449
Below CURL syntax solved my problem:
# curl -k -G -X 'GET' -H 'X-Auth-Token: 5127af39b7584d8c8897a0cad55accdc' -H 'Content-type: application/json' https://10.1.1.132/rest/rm-central/v1/recovery-sets -d "query=\"volumeType%20EQ%20'vvol'\""
Upvotes: 8
Reputation: 185630
Your URL seems wrong :
https://10.1.1.132/rest/rm-central/v1/recovery-sets?query="volumeType EQ 'vvol'"
especially the query=
part.
The quotes should be like this :
'https://10.1.1.132/rest/rm-central/v1/recovery-sets?query=foobar'
or with "double quotes"
Upvotes: 10