VMware Modern Apps Community
ericnipro
Community Manager
Community Manager
Jump to solution

API POST Content-Type: application/json

When I try to make a POST API call:

curl -X PUT --header "Content-Type: application/json" --header "Accept: application/json" -d '{ "name":"bob_test_alert_2", "condition":"ts(%22honeycomb.staging.SCS.app.NodeStateRepository-findOne-execution-time.count%22)%20%3E%200", "minutes":"2", "notifications":"bob%40domain.com", "severity":"SMOKE" }' "https://mydomain.wavefront.com/api/alert/create" -H 'X-AUTH-TOKEN: dd5b7179-c771-4212-8d09-b42d29aXXXXX'

I get the following response:

{"code":400,"message":"Unable to process JSON"}

---

Is JSON not supported ?

Community.... upload 1 .. download 10.
0 Kudos
1 Solution

Accepted Solutions
ericnipro
Community Manager
Community Manager
Jump to solution

Correct Answer by vasily@wavefront.com on Jun 29, 2016 10:21 AM

Hi Morgan,

The /alert/create method expects an application/x-www-form-urlencoded content type, so your call would look slightly different:

curl -X POST --header "Content-Type: application/x-www-form-urlencoded" -d 'name=bob_test_alert_2&condition=ts(%22honeycomb.staging.SCS.app.NodeStateRepository-findOne-execution-time.count%22)%20%3E%200&minutes=2&notifications=bob%40domain.com&severity=SMOKE' "https://mydomain.wavefront.com/api/alert/create" -H 'X-AUTH-TOKEN: dd5b7179-c771-4212-8d09-b42d29aXXXXX'

Please let us know if this works for you!

-Vasily

1 of 1 people found this helpful

Community.... upload 1 .. download 10.

View solution in original post

0 Kudos
2 Replies
ericnipro
Community Manager
Community Manager
Jump to solution

Correct Answer by vasily@wavefront.com on Jun 29, 2016 10:21 AM

Hi Morgan,

The /alert/create method expects an application/x-www-form-urlencoded content type, so your call would look slightly different:

curl -X POST --header "Content-Type: application/x-www-form-urlencoded" -d 'name=bob_test_alert_2&condition=ts(%22honeycomb.staging.SCS.app.NodeStateRepository-findOne-execution-time.count%22)%20%3E%200&minutes=2&notifications=bob%40domain.com&severity=SMOKE' "https://mydomain.wavefront.com/api/alert/create" -H 'X-AUTH-TOKEN: dd5b7179-c771-4212-8d09-b42d29aXXXXX'

Please let us know if this works for you!

-Vasily

1 of 1 people found this helpful

Community.... upload 1 .. download 10.
0 Kudos
ericnipro
Community Manager
Community Manager
Jump to solution

  Re: API POST Content-Type: application/json

   morgan_sziraki Level 1

 

  

 

  

thank you. I have that  working.. was hoping to post json

directly rather than parse and build .. no worries

On 29 Jun 2016 18:21, "vasily@wavefront.com" <

 

  

Community.... upload 1 .. download 10.
0 Kudos