Rails shopify_app - specifying the fields parameter in config/webhooks has no effect

New Member
3 0 0

Hi,

 

Based on the advice here, I tried specifying the fields I want to receive with a carts/update webhook, however specifying the fields has no effect. 

 

https://github.com/Shopify/shopify_app#webhooksmanager

 

Here is what the WebhooksManager sent:

 

[ActiveJob] [ShopifyApp::WebhooksManagerJob] [12ccc62b-e468-4638-b135-ca500bb71eaa] Performing ShopifyApp::WebhooksManagerJob (Job ID: 12ccc62b-e468-4638-b135-ca500bb71eaa) from Resque(default) with arguments: {:shop_domain=>"redacted", :shop_token=>"redacted", :webhooks=>[{:topic=>"customers/create", :address=>"https://41da118e.ngrok.io/webhooks/customers_create", :format=>"json"}, {:topic=>"customers/update", :address=>"https://41da118e.ngrok.io/webhooks/customers_update", :format=>"json"}, {:topic=>"checkouts/create", :address=>"https://41da118e.ngrok.io/webhooks/checkouts_create", :format=>"json"}, {:topic=>"checkouts/update", :address=>"https://41da118e.ngrok.io/webhooks/checkouts_update", :format=>"json"}, {:topic=>"carts/create", :address=>"https://41da118e.ngrok.io/webhooks/carts_create", :format=>"json", :fields=>["id", "token", "note", "updated_at", "created_at"]}, {:topic=>"carts/update", :address=>"https://41da118e.ngrok.io/webhooks/carts_update", :format=>"json", :fields=>["id", "token", "note", "updated_at", "created_at"]}, {:topic=>"orders/create", :address=>"https://41da118e.ngrok.io/webhooks/orders_create", :format=>"json"}, {:topic=>"app/uninstalled", :address=>"https://41da118e.ngrok.io/webhooks/app_uninstalled", :format=>"json"}]}

 

But when I receive a new webhook after this subscription is sent, carts/create and carts/update webhooks still send the line_items, for example.  I had previously also tried specifying which line_item fields I wanted and that also did not work, this example was a simpler test.  This is with the 2019-10 API.

 

Does the fields specification work?

 

Thanks,


KG

0 Likes
Shopify Staff
Shopify Staff
240 33 37

Hey @onspruce,

 

Is this the Cart Insights app on filtertown.myshopify.com? The fields property appears to be empty for all the webhooks that have been created.

 

It might be an issue with Shopify/shopify_app or I might have the wrong store/app. Let me know and I'll dig deeper.

0 Likes
Highlighted
New Member
3 0 0

Hi Scotty,

 

Yes, that is the right app -- I've been testing various updates in the past few days so the webhook subscriptions had the fields removed.  Today I've run some more subscription tests:

 

When I try to supply the fields array I am seeing an internal server error.  Perhaps you can supply an example config.webhooks topic subscription with the field line_items specified so that there is no server error, since the git doc example does not show the fields specified.  Maybe my formatting is incorrect for the fields line_items hash->array, but it comes out in the same generated format in the logs when I tried it in a few different ways.

 

log:

{:topic=>"carts/create", :address=>"https://2e3340ef.ngrok.io/webhooks/carts_create", :format=>"json", :fields=>["id", "token", "note", "updated_at", "created_at"]}, {:topic=>"carts/update", :address=>"https://2e3340ef.ngrok.io/webhooks/carts_update", :format=>"json", :fields=>["id", "token", "updated_at", "created_at", {:line_items=>["id", "quantity", "variant_id", "product_id", "sku", "title", "vendor"]}]}, {:topic=>"orders/create", :address=>"https://2e3340ef.ngrok.io/webhooks/orders_create", :format=>"json"},

 

[ActiveJob] [ShopifyApp::WebhooksManagerJob] [565d98e6-6682-4021-9740-231d1915a845] Error performing ShopifyApp::WebhooksManagerJob (Job ID: 565d98e6-6682-4021-9740-231d1915a845) from Resque(default) in 4035.66ms: ActiveResource::ServerError (Failed. Response code = 500. Response message = Internal Server Error.):
C:/Ruby26/lib/ruby/gems/2.6.0/gems/activeresource-5.1.0/lib/active_resource/connection.rb:159:in `handle_response'

...

 

When I omit the line_items in my specified fields, I still get the line items in the webhooks when I trigger a subscribed cart/create or cart/update event:

 

 {:topic=>"carts/create", :address=>"https://2e3340ef.ngrok.io/webhooks/carts_create", :format=>"json", :fields=>["id", "token", "note", "updated_at", "created_at"]}, {:topic=>"carts/update", :address=>"https://2e3340ef.ngrok.io/webhooks/carts_update", :format=>"json", :fields=>["id", "token", "updated_at", "created_at"]}

 

 

Thanks,

 

KG

0 Likes