Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

POSTing to admin API returns 401

POSTing to admin API returns 401

devHam
Tourist
8 0 3

Hi,

I'm trying to POST to the Admin API in order to register a webhook. I'm using the following code in a Node.js environment to make the post through Axios:

 

// register shopify webhooks
      await axios.post(
        `https://my-shop.myshopify.com/admin/api/2021-07/webhooks.json`,
        {
          webhook: {
            topic: "app/uninstalled",
            address:
              "https://us-central1-myapp-dev-8e897.cloudfunctions.net/processShopifyWebhookAppUninstalled",
            format: "json",
          },
        },
        { headers: { "Content-Type": "application/json", "X-Shopify-Access-Token": shopData.accessToken } }
      );

 

Assume shopData.accessToken is the stored access token that I saved when I completed oauth of my shopify node app as I installed it on my test shop. It is NOT my app API key or API secret key.

I don't understand why I'm getting a 401. What am I doing wrong here?

Replies 0 (0)