Support Questions

Find answers, ask questions, and share your expertise

I am getting error when i use the curl command with request info, can you please tell me is there any syntax issue?

avatar
Expert Contributor
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?

4 REPLIES 4

avatar
Rising Star

I guess there is a typo. Looks like space missing after "-d"

avatar
Master Mentor
@Ram D

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.

avatar

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.

avatar

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.