webhook for the topic "appsubscriptions/update" failing

Solved
Highlighted
Tourist
6 1 1

Hello,

 

I am trying to create a webhook for the topic "app_subscriptions/update" and all I am getting is an error

 

{"errors":"Could not find the webhook topic app_subscriptions\/update"}

 

This is what I am posting:

 

curl -d '{"webhook": { "topic": "app_subscriptions/update", "address": "https://www.web-stat.com/shopifyHook.pl", "format": "json"}}' -H "Content-Type: application/json" -H "X-Shopify-Access-Token: shop_accesstoken" -X POST https://some_shop_url/admin/api/2019-07/webhooks.json

 

I create other webhooks for other topics just fine. It's only "app_subscriptions/update" that causes this error.

 

If anyone has any ideas it would be much appreciated!

 

Thank you :)

 

Olivier

Web-Stat

https://www.web-stat.com

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1129 82 179

This is an accepted solution.

Hello @Web-Stat , 

 

At this time, this type of webhook can only be created with GraphQL mutations. 

 

Here's an example of a fairly basic one that would do the trick : 

 

mutation {
  webhookSubscriptionCreate(topic: APP_SUBSCRIPTIONS_UPDATE, webhookSubscription: {callbackUrl: "https://your-webhook-url.com/webhook", format: JSON}) {
    webhookSubscription {
      id
      callbackUrl
    }
  }
}

Hope it helps! 

0 Likes
Highlighted
Tourist
6 1 1

Thank you so much. Yes, it is very helpful... But I am not quite there yet!

 

Here is what I POST to https://some_shop/admin/api/2019-07/graphql.json (with the proper access token)

 

'mutation {
   webhookSubscriptionCreate(
      topic: APP_SUBSCRIPTIONS_UPDATE,
      webhookSubscription: {
         callbackUrl: "https://www.web-stat.com/shopifyHook.pl",
         format: JSON
      }
   )
   {
      webhookSubscription {
         id
         callbackUrl
      }
   }

}';    

 

And here is the response:

 

{"data":{"webhookSubscriptionCreate":{"webhookSubscription":null}},"extensions":{"cost":{"requestedQueryCost":10,"actualQueryCost":10,"throttleStatus":{"maximumAvailable":2000.0,"currentlyAvailable":1990,"restoreRate":100.0}}}}

 

So the call succeeds, but it seems no new webhook is being created.

 

Any idea what I might still be doing wrong?

 

Olivier

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1129 82 179

Hey again! 

 

That's interesting, the same mutation works for me. It's also my mistake for not adding userErrors to my query example, there's likely an error message being returned that you're not seeing because it isn't being requested as a return value. 

 

Try this instead and see if it uncovers anything : 

 

mutation {
  webhookSubscriptionCreate(topic: APP_SUBSCRIPTIONS_UPDATE, webhookSubscription: {callbackUrl: "https://www.web-stat.com/shopifyHook.pl",, format: JSON}) {
    webhookSubscription {
      id
      callbackUrl
    }
    userErrors {
      field
      message
    }
  }
}

 

0 Likes
Highlighted
Tourist
6 1 1

Thank you so much for the follow up! I implemented and I now get an error, although it does not tell me much:

 

{"data":{"webhookSubscriptionCreate":{"webhookSubscription":null,"userErrors":[{"field":["webhookSubscription","callbackUrl"],"message":"Address for this topic has already been taken"}]}},"extensions":{"cost":{"requestedQueryCost":10,"actualQueryCost":10,"throttleStatus":{"maximumAvailable":2000.0,"currentlyAvailable":1990,"restoreRate":100.0}}}}

 

I am not sure what "Address for this topic has already been taken". I thought maybe it meant that this webhook was already in place and could not be created again? So to verify, I did a GET to https://some_shop/admin/api/2019-07/webhooks.json to see what live webhooks I have (on the same shop) and I get the one for "app/uninstalled" which I created when setting the account up (using my 'default' API method):

 

{"webhooks":[{"id":681402597421,"address":"https:\/\/www.web-stat.com\/shopifyHook.pl","topic":"app\/uninstalled","created_at":"2019-08-15T09:08:33-07:00..."}]}

 

So. as you can see, my APP_SUBSCRIPTIONS_UPDATE is not in there.... And I am not sure what the error message means.

 

Olivier

Web-Stat

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1129 82 179

Hey again @Web-Stat ! 

 

That error message means that there is already a webhook set up with the same topic and target address. 

 

I am seeing an app_subscriptions/update webhook set up on the same shop in our database, it was created today at 09:49:37 UTC so it looks like at some point one of your requests succeeded. See if you can find the webhook with ID 687546630189 - that should be it!

0 Likes
Highlighted
Tourist
6 1 1

Josh,

 

I think we got this working now, thanks to your patience. The webhooks created OK on all the other accounts.

 

However, what still bothers me is that calls to:

 

https://novedge.myshopify.com/admin/api/2019-07/webhooks/687546630189.json

 

return {"errors":"Not Found"}

 

So the webhook may be created but it is invisible to:

 

/admin/api/2019-07/webhooks/687546630189.json

/admin/api/2019-07/webhooks.json
/admin/api/2019-07/webhooks/count.json

 

I tested all 3.

 

It may be that the hooks are working. I just don't know yet. We will see if our script is getting called or not...

 

Olivier

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1129 82 179

This is an accepted solution.

Hey again Olivier

 

Happy I was able to help! That's.... interesting that you can't see the webhook still though to say the least.

 

I can definitely see the webhook exists on that shop, and it's also tied to an API permission related to your Web-Stat app. Unfortunately outside of that though I can't really test the API responses to see this myself without API access to the shop. All signs point to your webhook being set up working normally though, but if you still run into issues for some reason don't hesitate to post back here and we can find a way to work through this. 

1 Like
Highlighted

Hello Josh, 

can you please elaborate this webhook in detail, like

-> WHEN THIS WEBHOOK TRIGGERS

-> WHAT DATA COMES WITH THIS TRIGGER

mutation {
  webhookSubscriptionCreate(topic:APP_SUBSCRIPTIONS_UPDATE,webhookSubscription:{callbackUrl:"https://execute-api.us-east-2.amazonaws.com/beta/webhook",format:JSON}){
   userErrors{
    field,
    message
  } ,
    webhookSubscription{
      callbackUrl,
      createdAt,
      id,
      topic,
      updatedAt
    }
  }
}

I had supposed it will give data when any app updates billing or add new purchase or un-installs app, then charge canceled data will be fired.
waiting for positive response

0 Likes