Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sample Check Definition JSON doesn't work #828

Closed
poy opened this issue Mar 30, 2015 · 4 comments
Closed

Sample Check Definition JSON doesn't work #828

poy opened this issue Mar 30, 2015 · 4 comments

Comments

@poy
Copy link
Contributor

poy commented Mar 30, 2015

When we try to register the check using the sample JSON:

{
  "check": {
    "id": "api",
    "name": "HTTP API on port 5000",
    "http": "http://localhost:5000/health",
    "interval": "10s",
    "timeout": "1s"
  }
}

We get back the following error:

curl -v -X PUT http://localhost:8500/v1/agent/check/register -d @/tmp/consul2.json
* Adding handle: conn: 0x7fb222003a00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fb222003a00) send_pipe: 1, recv_pipe: 0
* About to connect() to localhost port 8500 (#0)
*   Trying ::1...
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8500 (#0)
> PUT /v1/agent/check/register HTTP/1.1
> User-Agent: curl/7.30.0
> Host: localhost:8500
> Accept: */*
> Content-Length: 153
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 153 out of 153 bytes
< HTTP/1.1 400 Bad Request
< Date: Mon, 30 Mar 2015 21:57:12 GMT
< Content-Length: 18
< Content-Type: text/plain; charset=utf-8
<
* Connection #0 to host localhost left intact
Missing check name

I presume that the problem lies with casing in the JSON.

@ryanbreen
Copy link
Contributor

Looks like that's being PUT with a content-type of application/x-www-form-urlencoded. If you change your curl command to send application/json, does it work better?

@poy
Copy link
Contributor Author

poy commented Mar 30, 2015

Same results.

We got it to work with:

{
  "ID": "mem3",
  "Name": "Memory utilization",
  "HTTP": "http://localhost:8080/health",
  "Interval": "5s",
  "Timeout": "1s"
}

NOTE: This is without the -H "Content-Type: application/json" in the curl command

@armon
Copy link
Member

armon commented Apr 6, 2015

@apoydence The sample format you used is for config files, but it looks like you guys figured out the correct API format. Closing!

@armon armon closed this as completed Apr 6, 2015
@cohenaj194
Copy link

my check worked after I removed /health from "HTTP": "http://localhost:8080/health",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants