Shopify App "API Deprecation Notice" - Webhook /api/webhooks

LakshayLakshay
Shopify Partner
11 0 0

 

Hi,

I am facing an issue with my Shopify app where I receive a 400 Bad Request when the app is uninstalled from a store. I need help troubleshooting this problem.

Upon installation of the app, I can observe the following message in the console:

 

[shopify-api/WARNING] API Deprecation Notice 7/11/2023, 11:45:07 AM: {"message":"https://shopify.dev/api/usage/versioning#deprecation-practices","path":"https://store.myshopify.com/admin/api/2023-04/graphql.json","body":"{\n webhookSubscriptions(\n first: 250,\n after: null,\n ){\n edges {\n node {\n id..."} - Stack Trace: Error



 

When I check the subscribed webhooks of my store, I find that the "App_uninstalled" topic is subscribed with the callback URL as http://{url}/api/webhooks.

Upon investigating the node modules where the error is logged from, I noticed a variable called "deprecationReason".
However, when I log its value using console.log, it gives me "undefined".

Here is the code snippet where the "deprecationReason" is assigned:

deprecationReason = (0, http_1.getHeader)(response.headers, 'X-Shopify-API-Deprecated-Reason'); 
console.log("deprecationReason", deprecationReason); // Output: (deprecationReason undefined)


I even tried to make some api's in my node main file so that incase webhooks tries to hit the endpoint /api/webhooks it gets a 200 response.

 
This works when in request from postman
app.post("/api/test",(req,res)=>{
res.status(200).send("OK");
});
 This does not work when in request from postman
app.post("/api/webhooks", (req, res) => {
  res.status(200).send("OK");
});
 
Tried Approaches -
  1. https://github.com/Shopify/shopify-api-js/blob/main/docs/guides/webhooks.md
  2. https://community.shopify.com/c/webhooks-and-events/quot-failed-to-process-webhook-error-no-body-was...
  3. https://community.shopify.com/c/graphql-basics-and/api-deprecation-notice-deprecated-api-calls/td-p/...

 

I would greatly appreciate any insights, guidance, or suggestions to resolve this issue.

Thank you in advance!

L Kalra
Reply 1 (1)

diego-navarro
Shopify Partner
20 1 13

The API deprecation message is simply a warning that the API version you are currently using will be deprecated soon. You need to update to the latest API version (2023-07 at the time of this message) to eliminate this warning. To execute this update, navigate to your app setup configuration on partners.shopify.com. Additionally, ensure that your code is using the latest API version.

 

Regarding the proper registration of webhooks, I recommend updating to the most recent version of the Shopify API and following the webhooks guide available on their GitHub repository. Here is the repository link: https://github.com/Shopify/shopify-api-js