Consul service registration

574 views
Skip to first unread message

RPS

unread,
Aug 15, 2016, 3:35:38 PM8/15/16
to Consul
I'm running Consul 0.6.4 on Windows.

When I try to register a service via the HTTP API interface I get a 'Request decode failed' error.

curl -X PUT -d '{"ID":"NuSrv1","Name":"NuSrv1","Tags":["tagtest1","tagtest2","tagtest3"],"Address":"127.0.0.1","Port":80,"Check":{"HTTP":"http://127.0.0.1:80/","Interval":"15s","timeout":"1s"}}' http://127.0.0.1:8500/v1/agent/service/register

Request decode failed: invalid character '\'' looking for beginning of value

I try it without the single quotation marks, I get a similar error:

curl -X PUT -d {"ID":"NuSrv1","Name":"NuSrv1","Tags":["tagtest1","tagtest2","tagtest3"],"Address":"127.0.0.1","Port":80,"Check":{"HTTP":"http://127.0.0.1:80/","Interval":"15s","timeout":"1s"}} http://127.0.0.1:8500/v1/agent/service/register

Request decode failed: invalid character 'I' looking for beginning of object key string

I pushed the json through json lint, I get no failures.

I saw a similar entry in the groups about 2 years ago. The issue was attributed to the version of Consul used. But as mentioned, I'm using the latest version 0.6.4. When I posted that service-registration example, it too failed with a similar error.

What am I doing wrong?

Richard

Ivan Savčić

unread,
Aug 16, 2016, 6:01:06 AM8/16/16
to Consul
Can you perhaps lint the JSON file and upload it instead, using curl's -T, because escaping characters can be painful.

Something like this: curl -XPUT localhost:8080/v2/groups/helloworld -T helloworld-scale-up.json


Ivan

RPS

unread,
Aug 16, 2016, 9:29:11 AM8/16/16
to Consul
Thanks! It was the escaping characters.
Reply all
Reply to author
Forward
0 new messages