How To Use Webhooks With Shopify_app Gem?
for the last hours I've been trying to add a webhook to my Shopify app using the official shopify_app gem.
So I ran
rails g shopify_app:add_webhook -t products/update -a https://example.com/webhooks/products_update and saw every file getting generated as expected and checking the logs after installing my app in a Test Store also showed me that the webhook was initiated successfully.
However, after actually updating a product in the shop, I get an error saying:
ShopifyApp::MissingWebhookJobError (ShopifyApp::MissingWebhookJobError): shopify_app (7.2.9) app/controllers/shopify_app/webhooks_controller.rb:21:in `webhook_job_klass' shopify_app (7.2.9) app/controllers/shopify_app/webhooks_controller.rb:10:in `receive' actionpack (5.0.3) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
...going on for about 40 lines more and repeating itself after about 10-30 seconds, however, showing me the params before throwing it. I haven't changed the
products_job.rb, so it's still looking like this: (although I've tried to change it many times)
class ProductsJob < ActiveJob::Base def perform(shop_domain:, webhook:) shop = Shop.find_by(shopify_domain: shop_domain) shop.with_shopify_session do end end end
I'd be really happy to get any input on this, as I'm new to Shopify Apps and to Rails too (as you can probably tell ^^)
Your products update job file name should be like products_update_job.rb not products_job.rb also the contents should be as below:
class ProductsUpdateJob < ActiveJob::Base def perform(shop_domain:, webhook:) shop = Shop.find_by(shopify_domain: shop_domain) shop.with_shopify_session do end end end
Try this changes you will get it.
- → Trigger a click with jQuery using link_to of rails 4
- → Adding html data attribute to simple_forms input
- → How to remove parameters from the root URL if it does I18n
- → passing parameters to rails back end from an ajax call
- → Blocking ?page= in robots.txt
- → react js and rails Updating state on a component with active record relationship
- → State not passed into prop
- → Cannot read property 'modalIsOpen' of undefined
- → Objects not valid issue
- → How to map API params to model
- → Consuming webhooks shopify-api
- → How to add ScriptTag on shopify_api gem?