错误通过API创建Shopify网络挂接 [英] Error Creating Shopify Webhook through the API
问题描述
我想通过API来创建网络挂接。
当用户安装该应用程序(控制器):
I am trying to create a Webhook through the API. When the Customer installs the app (Controller):
def init_webhooks
topics = ["products/create", "products/update", "products/delete"]
topics.each do |topic|
webhook = ShopifyAPI::Webhook.create(format: "json", topic: topic, address: "http://#{@current_host}/webhooks/#{topic}")
raise "Webhook invalid: (#{topic}) #{webhook.errors}" unless webhook.valid?
end
end
下面是从日志中的错误:
Here is the error from the log:
RuntimeError (Webhook invalid: (products/create) #<ActiveResource::Errors:0x00000003bd7358>):
编辑:
我甚至尝试过制作一个网络挂接不块code,像这样:
I have even tried just creating one webhook without the block code like so:
webhook = ShopifyAPI::Webhook.create topic: "products/create", address: "http://myapp.com/webhooks/products/create", format: "json"
但我得到同样的事情。
But I get the same thing.
从我的路线文件:
match 'webhooks/products/create' => 'webhook#product_new'
match 'webhooks/products/update' => 'webhook#product_updated'
match 'webhooks/products/delete' => 'webhook#product_deleted'
我知道,授权和店实际上是在安装正确,因为如果我注释掉了加薪的错误路线,我再继续它显示一些测试订单,我的Shopify管理中创建测试产品的索引页。
I know that the authorization and shop is in fact installing correctly because if I Comment out the 'Raise' error line, I then proceed to the index page which displays some test orders and test products that I created within the Shopify Admin.
我不知道在哪里可以从这里走。谢谢
b
I'm not sure where to go from here. Thanks b
推荐答案
您使用的PARAMS(主题
,格式
,地址
)看起来对我好,但应该不会是 ShopifyAPI :: Webhook.new
而不是创建
?
The params you use (topic
,format
,address
) look good to me, but shouldn't it be ShopifyAPI::Webhook.new
instead of create
?
你现在有一个 shopify控制台在那里你可以很方便地测试红宝石code?
Did you now there is a shopify console where you can easily test your ruby code?
这篇关于错误通过API创建Shopify网络挂接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!