APIs & Integrations

haroldh
Participant

Webhook Help

SOLVE

I created a new app and got it authenticated using OAuth 2.0 to our HubSpot portal. Every time I try to test the subscription within the app, it keeps giving me a 400 error code (and nothing else). I use Postman to hit my API with the exact same sample JSON and URL and it hits. I'm unsure as to what's exactly happening.

 

[
  {
    "eventId": "100",
    "subscriptionId": 210677,
    "portalId": 6787449,
    "occurredAt": 1575663161592,
    "subscriptionType": "deal.propertyChange",
    "attemptNumber": 0,
    "objectId": 123,
    "changeSource": "CRM",
    "propertyName": "dealstage",
    "propertyValue": "sample-value"
  }
] 

 

Edit: I investigated and realized that in the sample JSON, the "eventId" is a string, but in the Webhook Event Details, it is a a number. Also, the JSON that's sent from the Webhook Event Details isn't an array.

{
  "objectId": 1148387968,
  "propertyName": "dealstage",
  "propertyValue": "1175058",
  "changeSource": "CRM_UI",
  "eventId": 930654971,
  "subscriptionId": 210178,
  "portalId": 6205670,
  "appId": 207344,
  "occurredAt": 1575656726200,
  "subscriptionType": "deal.propertyChange",
  "attemptNumber": 2
}

Any help?

0 Upvotes
1 Accepted solution
WendyGoh
Solution
HubSpot Employee
HubSpot Employee

Webhook Help

SOLVE

Hi @haroldh,

 

That's a great catch!

 

You're right that the Test subscription JSON payload would return something like this:

 

[
    {
        "eventId": "100",
        "subscriptionId": 141230,
        "portalId": {{portal Id}},
        "occurredAt": 1575942818226,
        "subscriptionType": "deal.propertyChange",
        "attemptNumber": 0,
        "objectId": 123,
        "changeSource": "CRM",
        "propertyName": "dealname",
        "propertyValue": "sample-value"
    }
]

whereas the actual JSON payload would be something like this:

 

{
  "objectId": 1148387968,
  "propertyName": "dealstage",
  "propertyValue": "1175058",
  "changeSource": "CRM_UI",
  "eventId": 930654971,
  "subscriptionId": 210178,
  "portalId": 6205670,
  "appId": 207344,
  "occurredAt": 1575656726200,
  "subscriptionType": "deal.propertyChange",
  "attemptNumber": 3
}

In this case, your code should be implemented to handle the exact JSON payload where the eventId is an integer instead of string.  

 

The payload would be in an array and the notification would be in JSON, something like this:

 

[
  {
    "objectId": 1246965,
    "propertyName": "lifecyclestage",
    "propertyValue": "subscriber",
    "changeSource": "ACADEMY",
    "eventId": 3816279340,
    "subscriptionId": 25,
    "portalId": 33,
    "appId": 1160452,
    "occurredAt": 1462216307945,
    "subscriptionType": "contact.propertyChange",
    "attemptNumber": 0
  },
  {
    "objectId": 1246978,
    "changeSource": "IMPORT",
    "eventId": 3816279480,
    "subscriptionId": 22,
    "portalId": 33,
    "appId": 1160452,
    "occurredAt": 1462216307945,
    "subscriptionType": "contact.creation",
    "attemptNumber": 0
  }
]

Could you try making these changes and see if it works?

View solution in original post

2 Replies 2
WendyGoh
Solution
HubSpot Employee
HubSpot Employee

Webhook Help

SOLVE

Hi @haroldh,

 

That's a great catch!

 

You're right that the Test subscription JSON payload would return something like this:

 

[
    {
        "eventId": "100",
        "subscriptionId": 141230,
        "portalId": {{portal Id}},
        "occurredAt": 1575942818226,
        "subscriptionType": "deal.propertyChange",
        "attemptNumber": 0,
        "objectId": 123,
        "changeSource": "CRM",
        "propertyName": "dealname",
        "propertyValue": "sample-value"
    }
]

whereas the actual JSON payload would be something like this:

 

{
  "objectId": 1148387968,
  "propertyName": "dealstage",
  "propertyValue": "1175058",
  "changeSource": "CRM_UI",
  "eventId": 930654971,
  "subscriptionId": 210178,
  "portalId": 6205670,
  "appId": 207344,
  "occurredAt": 1575656726200,
  "subscriptionType": "deal.propertyChange",
  "attemptNumber": 3
}

In this case, your code should be implemented to handle the exact JSON payload where the eventId is an integer instead of string.  

 

The payload would be in an array and the notification would be in JSON, something like this:

 

[
  {
    "objectId": 1246965,
    "propertyName": "lifecyclestage",
    "propertyValue": "subscriber",
    "changeSource": "ACADEMY",
    "eventId": 3816279340,
    "subscriptionId": 25,
    "portalId": 33,
    "appId": 1160452,
    "occurredAt": 1462216307945,
    "subscriptionType": "contact.propertyChange",
    "attemptNumber": 0
  },
  {
    "objectId": 1246978,
    "changeSource": "IMPORT",
    "eventId": 3816279480,
    "subscriptionId": 22,
    "portalId": 33,
    "appId": 1160452,
    "occurredAt": 1462216307945,
    "subscriptionType": "contact.creation",
    "attemptNumber": 0
  }
]

Could you try making these changes and see if it works?

haroldh
Participant

Webhook Help

SOLVE

Thank you for the help! I tested this morning with the new JSON structure expected and everything's working perfectly now. Thanks for your help

0 Upvotes