+ Start a Discussion
Test Dev 81Test Dev 81 

Webhook Intent to receive required

Hi Guys,
I am Integrating Xero with salesforce in my dev org
here's the validation code for the webhook
@RestResource(urlMapping='/XeroApi/*')
Global class RT_XeroApiClass {
    global static String jsonResults;
    @HttpPost
    global static Integer validatexero () {
        String xeroSignature = RestContext.request.headers.get('x-xero-signature');
        String xeroPayload = RestContext.request.requestBody.toString();
        Blob signedPayload = Crypto.generateMac('hmacSHA256', Blob.valueOf(xeroPayload), Blob.valueOf(System.Label.Webhook_Payload));
        String encodedPayload = EncodingUtil.base64Encode(signedPayload);
        RestContext.response.statusCode = encodedPayload == xeroSignature ? 200 : 401;
        
        return RestContext.response.statusCode;
    }
}
The Delivery URL in the webhook is
https://appl-dev-ed.my.salesforce.com/services/apexrest/XeroApi
when I am sending Intent to receive the status always shows "Intent to receive" required
User-added image
can you please tell me what I am missing here?
Thanks,
Rahul
Tyler Tran 94Tyler Tran 94
Maybe the problem is in 
Blob signedPayload = Crypto.generateMac('hmacSHA256', Blob.valueOf(xeroPayload), Blob.valueOf(System.Label.Webhook_Payload));
You should change the System.Label.Webhook_Payload to the Webhook Key in Xero.