Solved

failure to create CARTS_UPDATE webhook via GraphQL

hrstrand
Shopify Partner
19 2 12

I am trying to add a CARTS_UPDATE webhook. 

The code used is this : 

 

            const registration = await registerWebhook({
              address: `${EVENTHOST}/webhook/cart/update`,
              topic: 'CARTS_UPDATE',
              accessToken,
              shop,
              apiVersion: ApiVersion.October19
            });
            if (registration.success) {
              console.log('Successfully registered webhook!');
            } else {
              console.log('Failed to register webhook');
              console.dir(registration, { depth: null });

            }

However, the error I get is this : 

 

 {
   success: false,
   result: {
     data: {
       webhookSubscriptionCreate: {
         userErrors: [
           {
             field: [ 'webhookSubscription' ],
             message: 'You cannot create a webhook subscription with the specified topic'
           }
         ],
         webhookSubscription: null
       }
     },
     extensions: {
       cost: {
         requestedQueryCost: 10,
         actualQueryCost: 10,
         throttleStatus: {
           maximumAvailable: 1000,
           currentlyAvailable: 990,
           restoreRate: 50
         }
       }
     }
   }
 }

Any idea why this happens ? I am thinking it could be related to permissions, but there are no obvious permissions in this area. My current permission set is 

 

'read_products', 'write_products','read_script_tags','write_script_tags','read_checkouts', 'write_checkouts'

 

thanks for any pointers or ideas,

Peter

 

 

Developer of Realtime View : https://apps.shopify.com/realtime-view
Accepted Solution (1)
hrstrand
Shopify Partner
19 2 12

This is an accepted solution.

OK - added 

 

'write_orders','read_orders'
 
as scopes. This now works when creating CARTS_CREATE and CARTS_UPDATE webhooks.
 
Is there a place where it is listed what webhooks require which scopes? Also, the error message could be better than just "unable to create webhook"
 
thanks,
Peter
Developer of Realtime View : https://apps.shopify.com/realtime-view

View solution in original post

Replies 2 (2)

hrstrand
Shopify Partner
19 2 12

Any ideas on this? If I create a webhook with same code for PRODUCTS_CREATE topic, it works fine.

Is there a list of needed permission values for the different webhook topics?

 

thanks,

Peter

Developer of Realtime View : https://apps.shopify.com/realtime-view
hrstrand
Shopify Partner
19 2 12

This is an accepted solution.

OK - added 

 

'write_orders','read_orders'
 
as scopes. This now works when creating CARTS_CREATE and CARTS_UPDATE webhooks.
 
Is there a place where it is listed what webhooks require which scopes? Also, the error message could be better than just "unable to create webhook"
 
thanks,
Peter
Developer of Realtime View : https://apps.shopify.com/realtime-view