Webhook Content-Type not honoring "headers" in custom JSON setup

Trying to get my first webhook to work and I seem to be close, but no matter how I set it up, the content type appears to continually be set to “application/x-www-form-urlencoded” to my endpoint, rather than the “application/json” I specified. This is the (stripped down) setup I am using, and the “headers” display correctly in the overview page for the integration.

My webhook JSON:

{
"event": "temp",
"url": "https://server/api/v3/thing/",
"requestType": "POST",
"headers":{
    "Content-Type": "application/json",
	"Authorization": "Bearer abc123"
},
 "body": "[{\"importId\": \"x\",\"unitCode\": \"W\",\"channelId\": 1032,\"time\": \"{{PARTICLE_PUBLISHED_AT}}\",\"value\": \"{{PARTICLE_EVENT_VALUE}}\",\"estimated\": false,\"note\": \"\"}]",
 "noDefaults": true}

However, every time my webhook is triggered, I get a HTTP 415 error and this is what is shown in the WebHook overview for the request:

POST /api/v3/thing/ HTTP/1.1
Authorization: Bearer abc123
Content-Type: application/x-www-form-urlencoded
User-Agent: ParticleBot/1.1 (https://docs.particle.io/webhooks)
host: server
content-length: 0
Connection: keep-alive

What am I missing?

Much appreciated,
Ryan

I’d remove the outmost set if square brackets in your JSON
It should work like this

{
    "eventName": "demo",
    "url": "https://server/path",
    "requestType": "POST",
    "headers": {
        "Content-Type": "application/json"
    },
    "body": "{ \"the-value-is\": {{value}} }",
    "mydevices": true
}

Appreciate the response, ScruffR. I tried your suggestion (the API endpoint in question does accept an array of values… but obviously we’re only sending one in at this point). And, although the real API needs an Authorization header, I took it out so that the only head I have is the content-type. Still no go. The “request” that shows in the WebHook UI continues to show a content-type of “application/x-www-form-urlencoded”.

I’m up for other suggestions. I can certainly try other routes, I was just hoping that I could get this quick test running.

Again, I appreciate the input.

Are you creating the webhook via the console or CLI?

Online console.

Then trying CLI might be an option.
I think to remember that the console was a bit picky in that regard.

Just put your webhook definition in a .json file and use that for

particle webhook create <yourFile.json>
1 Like

Well, shoot. That was easy! Sorry I didn’t try that first. Worked like a charm and the correct content-type is now being sent.

1 Like