Webhooks subscription throwing error

Highlighted
Shopify Partner
8 0 2

I am having the exact same problem as you are. 

 

Followed the tutorial... successfully registered webhooks. But ngrok keeps giving me a 405 method not allowed on my webhook routes. 

 

Uninstalling and reinstalling the app had no effect - still 405. 

 

I'm not as familiar with koa-router, I normally just use express... I can see the line:

server.use(router.allowedMethods());

But we're not setting that anywhere, does it just infer the allowed methods based on what routes have been configured by the router?

Or does this have to do with a configuration of ngrok?

Thanks in advance.

2 Likes
Highlighted
Tourist
8 0 1

I'm having same problem, exact same server.js as example, everything works properly including registering the webhook, yet when I create a product ngrok is displaying:

 

POST /webhooks/products/create                                 403 Forbidden                    

POST //webhooks/products/create                                405 Method Not Allowed           

 

Removing and reinstalling isn't fixing it. I'm also occasionally seeing the following errors in my node app. 

 

Error: write EPIPE

      at afterWriteDispatched (internal/stream_base_commons.js:149:25)

      at writeGeneric (internal/stream_base_commons.js:140:3)

      at Socket._writeGeneric (net.js:776:11)

      at Socket._write (net.js:788:8)

      at doWrite (_stream_writable.js:435:12)

      at clearBuffer (_stream_writable.js:574:7)

      at Socket.Writable.uncork (_stream_writable.js:329:7)

      at connectionCorkNT (_http_outgoing.js:656:8)

      at processTicksAndRejections (internal/process/task_queues.js:81:21)

 

Also I'm running on MacOS Catalina, so I turned off the macos firewall, but didn't help.

0 Likes
Highlighted
Tourist
8 0 1

OK, I found the problem. Registering the webhook using

 

const registration = await registerWebhook({
address:`${HOST}/webhooks/products/create`,
topic: 'PRODUCTS_CREATE',
accessToken,
shop,
apiVersion: ApiVersion.October19
});
 
 
while 
 
router.post('//webhooks/products/create', webhook, (ctx) => {
console.log('received webhook: ', ctx.state.webhook);
});
 
 
I knew that this code obviously works for everyone else, so I traced my mistake to misdeclaring host as:
 
1 Like
Highlighted
New Member
2 0 0

Thanks for the solution - that was driving me crazy. Kind of obvious after the fact. 

0 Likes
Highlighted
New Member
1 0 0

I'm having the same problem as well. I'm using the exact same file from the tutorial and my HOST is declared correctly. However, I'm still receiving the 405 forbidden method error on NGROK. I'm trying to receive a product creation webhook from the Shopify admin. I'm able to successfully register the webhook, but cannot receive it. Any other tips you might have?

0 Likes