I’ve got an action hooks that looks like this:
{
type: 'ACTION_HOOK',
httpMethod: 'POST',
uri: 'https://xxx.eu.ngrok.io/api/powerups/hubspot/card',
label: 'Some Value',
}
When selecting that value, Hubspot fires of a POST request and waits for it to return a 200 on my side. Once it has done that, it fires for a GET request to me again.
The problem I have is that the GET request validates just fine, but the POST doesn’t. Leading me to believe it’s not my code that’s wrong, but somehow validating action hooks work differently.
My code:
// v3
const hmac = crypto.createHmac(
'sha256',
process.env.HUBSPOT_CLIENT_SECRET!
);
let str: string;
if (method === 'POST') {
str = method! + url + JSON.stringify(body) + Number(timestamp);
} else {
str = method! + url + Number(timestamp);
}
const hash = hmac.update(str).digest('base64');
// v2
if (method === 'POST') {
str = clientSecret + method! + url + JSON.stringify(body);
} else {
str = clientSecret + method! + url;
}
const hash2 = crypto.createHash('sha256').update(str).digest('hex');