Created 03-07-2016 06:29 PM
curl -u admin:password -i -H 'X-Requested-By:ambari' -X PUT –d'{"RequestInfo":{"context":"Stop DATANODE"},"Body":"HostRoles":{"state":"INSTALLED"}}' http://viceroy10:8080/api/v1/clusters/et_cluster/serf120int.etops.tllsc.net /host_components/DATANODE
Error :
curl: (3) [globbing] nested braces not supported at pos 18 HTTP/1.1 404 Not Found User: admin et-Cookie: AMBARISESSIONID=1mc7f72vpbasxqwkzdiyphjv2;Path=/;HttpOnly Expires: Thu, 01 Jan 1970 00:00:00 GMT Content-Length: 0 Server: Jetty(8.1.17.v20150415) curl: (3) <url> malformed
If i use the curl command without using request info, it is working fine.
curl -u admin:password -i -H 'X-Requested-By: ambari' -X PUT -d '{"HostRoles": {"state": "INSTALLED"}}' http://viceroy10:8080/api/v1/clusters/et_cluster/hosts/serf120int.etops.tllsc.net/host_components/DA...
What is the reason for failing above curl command?
Created 03-07-2016 06:47 PM
I guess there is a typo. Looks like space missing after "-d"
Created 03-07-2016 09:14 PM
try the suggested space after -d suggestion and make sure there is no space in the URL of the first command example. Also, please keep in mind you're posting API calls to your environment, your password was right in the API call as well as server URL. I suggest you immediately change it, I renamed the password but who knows how many people have seen it. Next time also mask the URL to your real server names.
Created 03-07-2016 11:40 PM
Also, many times the terminal's stty erase isn't good for the curl commands, and hence a backspace etc introduces unexpected characters for curl. I would recommend typing it in a notepad like application and then copy paste the whole line.
Created 03-08-2016 02:15 PM
The JSON in the payload is incorrect:
{"RequestInfo":{"context":"Stop DATANODE"},"Body":"HostRoles":{"state":"INSTALLED"}}
Should be:
{"RequestInfo":{"context":"Stop DATANODE"},"Body":{"HostRoles":{"state":"INSTALLED"}}}
Note the added set of { and } around the HostRoles data.