TypeError: Cannot read property 'webhookSubscriptions' of undefined

sadafsid
New Member
3 0 0

I tried to register Bulk operation webhook

 

try {
      const response = await Shopify.Webhooks.Registry.register({
        shop,
        accessToken,
        path: '/webhooks/products',
        topic: 'BULK_OPERATIONS_FINISH',
        webhookHandler: async (topic, shop, body) => {
          console.log('inside');
        },
      });
      console.log(JSON.stringify(response));
      return response;
    } catch (error) {
      console.log('error : ', error);
    }

 

 it is giving me the error :  

 

error :  TypeError: Cannot read property 'webhookSubscriptions' of undefined
    at Object.<anonymous> (S:\myApp\Codebase\myAppnode\node_modules\@shopify\shopify-api\dist\webhooks\registry.js:112:51)
    at step (S:\myApp\Codebase\myAppnode\node_modules\tslib\tslib.js:143:27)
    at Object.next (S:\myApp\Codebase\myAppnode\node_modules\tslib\tslib.js:124:57)
    at fulfilled (S:\myApp\Codebase\myAppnode\node_modules\tslib\tslib.js:114:62)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
undefined

 


In doc there is no scope dependency is defined here: https://shopify.dev/api/admin-graphql/2021-10/enums/WebhookSubscriptionTopic

 my app scopes are

 

SCOPES=read_price_rules,write_price_rules,read_orders,read_discounts,write_discounts,read_products,write_products,write_customers,write_draft_orders,read_inventory,read_product_listings,write_script_tags,read_script_tags,read_themes,write_themes,read_reports,write_reports

 

Please guide me on what I am missing here.

 

 

 

 

Reply 1 (1)
guivieira
Shopify Staff
1 0 0

Hi,

 

I'm glad you are adopting this new feature.

The BULK_OPERATIONS_FINISH webhook topic is only available from Admin API version 2021-10 onwards

If you are using shopify-cli, you can change the API version on server/server.js. If the October21 version is not available, you will need to upgrade the @shopify/shopify-api package. 

 

Thanks,