Question

401 - 'Invalid API Key' error when updating a Shopify order via Zapier webhooks

  • 14 October 2022
  • 8 replies
  • 535 views

Context: I followed this Zapier tutorial for updating an order in Shopify everytime a customer purchases a certain product.

My issue is that when I test the webhook I get this error:

[API] Invalid API Key Or Access Token (Unrecognized Login Or Wrong Password)

 

This is my webhook setup:
 

 

And these are my API keys in Shopify:
 


I also enabled all the permissions from Shopify, in case that was the reason why I get this error, but still no success.

Also, when I’m logged in Shopify and I try to access manually to the URL I provided to the webhook (i.e. https://00d…etc…/orders/4911250604276.json), I can access it no problem.

Why my webhook doesn’t want to work?


8 replies

Userlevel 7
Badge +9

Heya @onlinedaniel! Sorry to hear you’re running into that error!

I hope you don’t mind, I went ahead and moved your question over to our Code & Webhooks forum to see if we can’t get some more technical set of 👀’s on this for us. 

okay. i can apply on my website 

Nobody knows?

Userlevel 7
Badge +8

Hi @onlinedaniel 

 

2 things I have noticed: 

 

Change 2022-07 to 2022-10 (latest version) 

 

And the Header Authorization should also be removed as a whole. 

 

Hopefully this works :) 

Hi @onlinedaniel 

 

2 things I have noticed: 

 

Change 2022-07 to 2022-10 (latest version) 

 

And the Header Authorization should also be removed as a whole. 

 

Hopefully this works :) 


Hi @MohSwellam ,

Thank you so much for your answer. I followed your advices and I updated the API to the 2022-10 version and I removed the Header Authorization:


And I also updated the Shopify private app accordingly:


But still no luck:

 

Userlevel 7
Badge +8

Hi @onlinedaniel , 

 

I took a closer look at the API documentation, here is what you need to do:


Method should be POST (not PUT)

 

URL should be "https://{your-development-store.myshopify.com}/admin/api/2022-10/orders.json"


Header 1 "X-Shopify-Access-Token” and the value is the API key

Header 2 should stay the same "Content-Type: application/json"


The API version in the referenced article is too old so Im not able to check it, but I believe the above should work

Hi @onlinedaniel , 

 

I took a closer look at the API documentation, here is what you need to do:


Method should be POST (not PUT)

 

URL should be "https://{your-development-store.myshopify.com}/admin/api/2022-10/orders.json"


Header 1 "X-Shopify-Access-Token” and the value is the API key

Header 2 should stay the same "Content-Type: application/json"


The API version in the referenced article is too old so Im not able to check it, but I believe the above should work

 

Hi @MohSwellam ,

I updated the webhook following your indications:

 

But I still get the same error :( In the X-Shopify-Access-Token value I used the public API key (shown in the screenshot above), but when I replace it with the secret key it also fails. I researched about it and supposedly the X-Shopify-Access-Token value should be filled with some “access_token” variable, but I haven’t understood whether it is somehow generated from both API keys or if it’s enough to just insert the public (or the private) key there, which doesn’t seem to do the trick.

On the other hand, is it for sure that the method should be POST? I’m just asking because I want to update an existing order, and from the Shopify docs I’m told to use PUT on /orders/{order_id}.json. 

Thank you again for your help.

Userlevel 7
Badge +8

Hi @onlinedaniel 

 

Im really sorry, you are updating an existing order not creating a new one, then yes its PUT, I thought you are creating a new order, my mistake. 

 

On the other hand, it seems that the access token is different than the API Key and the Client Secret, its becoming more complicated :D (Please remove the data above, anyone can access your store using this data!) 

 

It seems that you need to contact Shopify for the access token ? 

Here is a few resources that you will need

 

https://shopify.dev/api/admin-rest/2022-10/resources/accessscope

https://shopify.dev/api/usage/access-scopes

https://shopify.dev/apps/auth/oauth/getting-started#ask-for-permission

Reply