APIs & Integrations

justanna
Participant

Webhooks failing validation on contacts with emojis

Hi all! My HubSpot webhooks are passing validation on most contacts except those with emojis in the req.body. I tried several different sha256 hashing libraries, but every time the hash I generate does not match up with HubSpot's x-hubspot-signature header even though all other contacts succeed. I am using node.js so if anyone knows of an npm package or method that will get my contacts to consistently validate, I'd be happy to hear it! Thanks!

0 Upvotes
2 Replies 2
WendyGoh
HubSpot Employee
HubSpot Employee

Webhooks failing validation on contacts with emojis

Hey @justanna,

 

I hope all is well with you 🙂

 

When testing this out, I'm able to see that if there's an emoji being added into the request body, the signature doesn't match up.

 

Digging further into this, the reason why the signature doesn't match up is because of the "\" parameter and we would need to do a string escape.

 

const crypto = require('crypto')
var jsesc = require('jsesc');

const clientSecret = "{{client_secret}}";

const body = '[{"objectId":123,"propertyName":"firstname","propertyValue":"testName\uD83D\uDE00","changeSource":"CRM_UI","eventId":123,"subscriptionId":123,"portalId":123,"appId":123,"occurredAt":1563782798942,"subscriptionType":"contact.propertyChange","attemptNumber":0}]';
const hashString = clientSecret + jsesc(body);

const signature = crypto.createHash('sha256').update(hashString).digest('hex')

console.log(signature);

Hope this helps!

0 Upvotes
justanna
Participant

Webhooks failing validation on contacts with emojis

Great! I'll give this a shot! Thanks for responding!

0 Upvotes