I’m trying to debug the processing of webhooks. Shopify is firing webhooks to my server and the webhooks are received.
My problem is that webhook ctx.request.body is undefined. That means, the webhook request comes without a body and without a body I cannot compute the Sa256 to compare to the header. This is the request in the latest webbhook I got
{
method: 'POST',
url: '/webhook_subscriptions_update',
header: {
host: 'shopifykshwishlist.herokuapp.com',
connection: 'close',
'user-agent': 'Shopify-Captain-Hook',
accept: '*/*',
'accept-encoding': 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
'content-type': 'application/json',
'x-shopify-api-version': '2021-10',
'x-shopify-hmac-sha256': 'MwsDd+gZNpRcpLiZu58qXzZONRgI3N0MIn0JAtxViyo=',
'x-shopify-shop-domain': 'vue-dawn.myshopify.com',
'x-shopify-topic': 'app_subscriptions/update',
'x-shopify-webhook-id': '58d3174d-84d0-4104-a41a-9da342c66ae3',
'x-request-id': '50c2920e-6e31-463f-bb01-6693b9540a78',
'x-forwarded-for': '34.122.195.146',
'x-forwarded-proto': 'https',
'x-forwarded-port': '443',
via: '1.1 vegur',
'connect-time': '0',
'x-request-start': '1643299376798',
'total-route-time': '0',
'content-length': '304'
}
}
All the code I have tried uses the ctx.request.body to compute the Sa256.
I have tried to use the code supplied by Shopify but it fails and says that the webhook has not been registered, although I got success registering the webhook. Also I have the mandatory webhooks registered in the App setup in the developer dashboard.
try {
await Shopify.Webhooks.Registry.process(ctx.req, ctx.res);
console.log(`Webhook processed, returned status code 200`);
} catch (error) {
console.log(`Failed to process webhook: ${error}`);
}
The above code fails.
It may be that the person reviewing my app is firing these webhooks for me to debug and that those webhooks are not like the real ones, they are missing the body.
HELP SHOPIFY!!!