2
votes

Backdrop: Am building a shopify app using a test store provided by shopify. #Python #Django-

Problem: I have setup shopify webhooks for my test store using the python API for the topics "products/update" and "products/delete". But my endpoints are not called by shopify when I manually update or delete a product on my test store.

My detective work so far: I have checked the following:

  1. I have confirmed that the webhooks were successfully created using the API. I simply listed all the existing webhooks using the API for the store and mine are there.

  2. The address/URL I specified in the webhook for shopify to call in the event of a product update or delete is a public url, as in it is not on my localhost. (not 127.0.0.1:8000 etc.)

  3. My webhook endpoint is fine. When I manually call my endpoint in a test case, it does what it should.

  4. I contacted the shopify apps support guys, and I was asked to post this issue here.

Another minor issue is that I cannot find in the shopify API docs exactly what JSON/XML the webhook will POST to my URL in the event it should. So I do not know what that JSON will look like...

Any help would be appreciated!

2
The webhook will POST the product that has been updated. To verify the contents you can add a webhook that points to a service like postcatcher.inDavid Underwood
Please post the store name and API key you're using (but not the shared secret), these will help us debug the issue. Thanks!David Underwood
Use postcatcher.in/requestb.in to see if the webhooks are actually firing, or just take a look at your access_log on your server (if on Apache) to see if you are receiving the request. Also try making the webhooks manually through the backend with the same URL (to see if it's a problem with API webhooks or just webhooks in general).Andrew Ryno

2 Answers

1
votes

I don't have the creds to comment apparently, so I'll put this in an "answer" - to use the term very loosely - instead. I ran into something similar with the Python API, but soon realized that I was doing it wrong. In my case, it was toggling the fulfillment status, which then fires off an email notifying customers of a download location for media.

What I was doing wrong was this: I was modifying the fulfillment attribute of the order object directly. Instead, the correct method was to fetch / create a fulfillment object, modify that, point the order attribute to this object, than save() it. This worked.

I don't know if this is your issue as there's no code posted, but I hope this helps.

--Matt

1
votes

Thanks for the answers guys, but I found out that the issue was something else.

I forgot to make a CSRF exemption for the POST request URL that Shopify calls and also forgot to add a trailing slash '/' at the end of the URL I told the webhook to call.

I guess I would have caught these errors if I used something like postcatcher.in as suggested in the comments above. I din't bother doing that as it looked like too much of a hassle.