APIs & Integrations

Patrick_El-Hage
Member

Creating webhook subscriptions with the hubspot API

I’m trying to create webhook subscriptions using the API rather than the UI. To do so I’m executing the following :

curl -XPOST "https://api.hubapi.com/webhooks/v1/{APPID}/subscriptions?hapikey={DEV_HAPI_KEY}&userId={USERID}" -d'{"subscriptionDetails":{"subscriptionType":"company.creation"},"enabled":true}'

The response I’m getting is just and empty status 200 response. I assumed this meant the call had functioned but my webhook list is still empty. Because I’m getting an empty response (with a 200 status which I assumed indicated success), I have no idea what I’m doing wrong here. I’ve played around with the data content of the request, and even sending complete nonsense like {"BLA": "BLA"} yields the same response. Am I doing something wrong here ? If so, how can I move forward and debug it ?

0 Upvotes
2 Replies 2
Dadams
HubSpot Employee
HubSpot Employee

Creating webhook subscriptions with the hubspot API

Hi @Patrick_El-Hage

You should be getting an error for this. You need to include the content-type: application/json header with this request, otherwise it won’t actually be accepted (curl defaults to Content-Type: application/x-www-form-urlencoded).

I’ll file an issue for this to make sure we’re returning an error when the content-type isn’t correct.

0 Upvotes
Patrick_El-Hage
Member

Creating webhook subscriptions with the hubspot API

Hello @dadams,

Thanks for the quick response, that fixed things for me. Indeed a non 200 code would be helpful, even if the exact error isn’t identified, as I wasn’t sure if something was wrong with my request or if I needed to configure something differently on the app end.

Thanks again for the help.

0 Upvotes