Reputation: 235
I'm trying to create a Webhook on Contentful.com via their Content Management API. Command as follows (note that I've tweaked respective ID's for security):
curl -X PUT -H 'Content-Type: application/vnd.contentful.management.v1+json' -H 'Authorization: Bearer c8c3ef46d5dbfe3c841a3b4bff1ee89449669ffd407d1a62c7a0ecbad9c3120' -H 'Content-Length: 33' 'https://api.contentful.com/spaces/du8mcuj2d5la/webhook_definitions/1CtkR6S5oUqWywgEO2i0xx' -d '{"url":"https://xxx.parseapp.com"}'
It appears no matter what URL (other than https://www.example.com
) I use in the final object I get the following response:
{
"sys":{
"type":"Error",
"id":"InvalidJsonRequestBody"
},
"requestId":"85f-1338857905",
"message":"The body you sent is not valid JSON."
}
I've validated with Paw (http://luckymarmot.com/paw
) that the endpoint pass accepts inbound POST requests and (returns a 200 response code). Just to stress if I switch out https://xxx.parseapp.com
to https://www.example.com
it creates the webhook. Anything else it appears to complain.
Upvotes: 0
Views: 583
Reputation: 2000
It seems that the issue is quite simple:
The payload length does not match the Content-Length
header.
{"url":"https://xxx.parseapp.com"}
is 34 bytes, but you've set the header explicitly to -H 'Content-Length: 33'
. (33 is only true for the example.com example.)
If you adjust the length to -H 'Content-Length: 34'
it should work fine.
Also you could leave this header out when experimenting with curl
as it will automatically set it to the correct value (check with -v
option).
In general most HTTP clients/libraries should set the Content-Length header on their own when doing POST/PUT requests.
Upvotes: 4