Consul: Can't register service with HTTP API by curl in command line ,"Missing Service Name"

Created on 28 Apr 2014  ·  4Comments  ·  Source: hashicorp/consul

Thanks for develop this amazing system. My team are testing consul on 5 nodes small cluster(3 server+2 client)

Consul v0.1.1.dev (b8d185af405a21ce84f75e2bb59beaeec08c7f84+CHANGES)
Consul Protocol: 1 (Understands back to: 1)

when running the following:

curl -d '{"Service":{"ID":"1234","Name":"mysql-1","Tags":["slave"],"Port":3306,"check":{"Name":"MySQL Service Check","Script":"/root/mysqlcheck.sh orz1bsg","Interval":"3s"}}}' http://127.0.0.1:8500/v1/agent/service/register

It failed to register a service and reports "missing service name". Tried on each node and got the same result.

It works Ok when write the above json to a file like /etc/consul.d/mysql_chk.json and loaded when consul join the cluster or using kill -s SIGHUP.

Appreciate if there is clue.

Thanks,

Joe

Most helpful comment

@deadjoe Ah nevermind! I just realize you have an extra layer of nesting. The "Service" object should actually be the top level object. That nested format is only used for the config files so that the parser can disambiguate. The API does not use that top level object.

All 4 comments

@deadjoe There are some weird case-sensitivity issues lurking in the API parser. There have been some PR's to resolve some of them. Can you try with the latest build from master to see if this issue persists?

@deadjoe Ah nevermind! I just realize you have an extra layer of nesting. The "Service" object should actually be the top level object. That nested format is only used for the config files so that the parser can disambiguate. The API does not use that top level object.

Thanks a lot.
2014年4月29日 上午8:13于 "Armon Dadgar" [email protected]写道

@deadjoe https://github.com/deadjoe Ah nevermind! I just realize you
have an extra layer of nesting. The "Service" object should actually be the
top level object. That nested format is only used for the config files so
that the parser can disambiguate. The API does not use that top level
object.


Reply to this email directly or view it on GitHubhttps://github.com/hashicorp/consul/issues/82#issuecomment-41629683
.

Thanks a lot. It works now.
2014年4月29日 上午8:13于 "Armon Dadgar" [email protected]写道

@deadjoe https://github.com/deadjoe Ah nevermind! I just realize you
have an extra layer of nesting. The "Service" object should actually be the
top level object. That nested format is only used for the config files so
that the parser can disambiguate. The API does not use that top level
object.


Reply to this email directly or view it on GitHubhttps://github.com/hashicorp/consul/issues/82#issuecomment-41629683
.

Was this page helpful?
0 / 5 - 0 ratings