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)