APIs & Integrations

BigDawg5508
Member

Webhooks test - 400 error

SOLVE

Hello,

 

I've created a webhook subscription, seemingly meeting any and all pre-requisite requirements. This subscription is for the contacts.created event.

 

I've provisioned the URL, as well as the POST endpoint (HTTPS) and accepting the expected JSON payload.

 

However, when testing the API from within Hubspot, I only receive a 400 error.

 

Any assistance would be greatly appreciated!

0 Upvotes
1 Accepted solution
BigDawg5508
Solution
Member

Webhooks test - 400 error

SOLVE

@Jaycee_Lewis , thank you so much for your reply. It is a private app, and I have to do a small walk of shame, because I did identify the issue...

 

When I created my object for deserialization from the JSON payload sent from the Hubspot webhook, 'apparently' I created the 'objectId' field as a string vs. a number 😞

 

When I changed the type to a number (as shown in the webhooks docs/screenshot) all was good in the world again. Total rookie move and my apologies for taking up your time for an error on my behalf.

 

schema.png

View solution in original post

7 Replies 7
AddaxLab
Member

Webhooks test - 400 error

SOLVE

Hey @BigDawg5508,

We do not have enough information here, and it would be great to have more details.

A 400 error occurs when a browser sends a request to a web server that the server cannot understand or process correctly. So, check what type of data your API expects—webhooks send an array of objects but not an object (this is a pretty common mistake)

02974_0-1721150197827.png

 


0 Upvotes
BigDawg5508
Member

Webhooks test - 400 error

SOLVE

Howeve maybe I spoke to soon. The 'testing' of the webhook works fine now. However, when I created a contact and the webhook triggered, I actually still receive the 400/bad request.

 

See the Postman request and response below. For now, my API is just echoing the request back in the response.

 

postman.png

0 Upvotes
BigDawg5508
Member

Webhooks test - 400 error

SOLVE

Hey @AddaxLab , so definitely 10-4 on the 400, and yes, I may have said 'object' in my original post but my API is in fact setup to receive a JSON array. However, a rookie movie on my part that I happened to notice yesterday. 'Apparently' when I created my object that the Hubspot payload would be deserialized to, in error I created the 'objectId' field as a string vs a number lol. So, when it tried to deserialize it, it was failing and a 400 in this case definitely makes sense. So, another case of a dev just going to quickly and making a rookie mistake.

 

I can't thank you enough for reaching out to assist!!

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Webhooks test - 400 error

SOLVE

Hi, @BigDawg5508 👋 Thanks for reaching out. Is this webhook set up using a Private App or using a Public App? Hey @dsmarion @PBaxter @stefen, do you have any webhook setup troubleshooting tips you can share with @BigDawg5508?

 

Thank you very much for taking a look! — Jaycee 

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
BigDawg5508
Member

Webhooks test - 400 error

SOLVE

Howeve maybe I spoke to soon. The 'testing' of the webhook works fine now. However, when I created a contact and the webhook triggered, I actually still receive the 400/bad request.

 

See the Postman request and response below. For now, my API is just echoing the request back in the response.

 

postman.png

0 Upvotes
BigDawg5508
Solution
Member

Webhooks test - 400 error

SOLVE

@Jaycee_Lewis , thank you so much for your reply. It is a private app, and I have to do a small walk of shame, because I did identify the issue...

 

When I created my object for deserialization from the JSON payload sent from the Hubspot webhook, 'apparently' I created the 'objectId' field as a string vs. a number 😞

 

When I changed the type to a number (as shown in the webhooks docs/screenshot) all was good in the world again. Total rookie move and my apologies for taking up your time for an error on my behalf.

 

schema.png

Jaycee_Lewis
Community Manager
Community Manager

Webhooks test - 400 error

SOLVE

Hey, @BigDawg5508 👋 Thanks for taking the time to come back and let us know how you solved the issue. I definitely learn from my mistakes and my victories 😊 — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes