Shopify Public app webhook

Solved

Shopify Public app webhook

yanteb
Shopify Partner
34 0 4

i got this email from shopify:

Your webhook for products/create at https://app.com/webhooks/orders/create is failing to return a successful response.

 

This webhook has been attempted 2 times. If your webhook continues to fail, it will be removed and your application will not receive any more notifications.

Im getting this message because Shopify is telling me they are not getting a 200 successful response after receiving the webhook

 

this is what my webhook looks like:

 

 

 router.post('/webhooks/orders/create', webhook, (ctx) => {
        ctx.status  = 200
        ctx.body = {
       status: 'success',
       message: 'Successfully updated.'
     };
      console.log('received order webhook: ', ctx.state.webhook);
    ])

 

 

as you see i have both     

 

ctx.status  = 200

and 

 

 

 

ctx.body = {
       status: 'success',
       message: 'Successfully updated.'
     };

 

 
and they are telling me i am not sending a success response. Anybody know what i have to do here?
Accepted Solution (1)

Jayvin
Shopify Partner
284 42 89

This is an accepted solution.

Hi yanteb,

I am not familiar with Koa as well but maybe you should set the status as follows:

ctx.response.status = 200 as mentioned here => https://github.com/koajs/koa/blob/master/docs/api/response.md

banned

View solution in original post

Replies 2 (2)

olivert
Explorer
51 12 19

Hey Hey, 

I've had trouble in the past with webhooks as shopify wants a response within 5 seconds or it errors. 
I had to return the response immediately, then do the processing later. 

Your code below should return instantly, but is there more it's doing in the background?

I'm not that good with Koa, 
but another troubleshooting step would be to call your API endpoint with Postman or another program, to see what's happening. 
I would usually mimic the call Shopify is making and see what's happening.

 

Jayvin
Shopify Partner
284 42 89

This is an accepted solution.

Hi yanteb,

I am not familiar with Koa as well but maybe you should set the status as follows:

ctx.response.status = 200 as mentioned here => https://github.com/koajs/koa/blob/master/docs/api/response.md

banned