2012-07-31 61 views
0

我有一家商店,有權讀取|寫下訂單和產品。我設置了一些Webhook,現在我想刪除它們。我收到401錯誤。刪除Webhook

Starting with 4 webhooks 
Trying to delete webhook 1982492 
Error nil, Failed. Response code = 401. Response message = Unauthorized. 
Trying to delete webhook 1982494 
Error nil, Failed. Response code = 401. Response message = Unauthorized. 
Trying to delete webhook 1982496 
Error nil, Failed. Response code = 401. Response message = Unauthorized. 
Trying to delete webhook 1982498 
Error nil, Failed. Response code = 401. Response message = Unauthorized. 
Ended with 4 webhooks 

那麼,如何刪除在產品和訂單上設置的Webhooks呢?

+0

您是否使用與刪除它們相同的應用程序密鑰創建了這些webhook? – 2012-07-31 22:41:43

+0

是的......這是一個簡單的練習。我意識到我不需要3/4創建的webhook,所以我試圖刪除它們。使用rake任務創建它們,應該可以使用rake任務來殺死它們。 – 2012-08-01 03:38:23

回答

1

這裏是我的Shopify控制檯顯示它正常工作一段對話:

$ shopify console 
using iliketurtles.myshopify.com 
irb(main):001:0> include ShopifyAPI 
=> Object 
irb(main):002:0> w = Webhook.create topic: "orders/create", address: "http://whatever.place.com", format: "json" 
=> #<ShopifyAPI::Webhook:0x007f8ff1895778 @attributes={"topic"=>"orders/create", "address"=>"http://whatever.place.com", "format"=>"json", "id"=>2026848, "created_at"=>"2012-08-10T15:11:25-04:00", "updated_at"=>"2012-08-10T15:11:25-04:00"}, @prefix_options={}, @persisted=true, @remote_errors=nil, @validation_context=nil, @errors=#<ActiveResource::Errors:0x007f8ff18948c8 @base=#<ShopifyAPI::Webhook:0x007f8ff1895778 ...>, @messages={}>> 
irb(main):003:0> w.destroy 
=> #<Net::HTTPOK 200 OK readbody=true> 

正如其他人所提到的,我覺得您的問題與權限相關。

+1

有趣。由於rake任務A創建Webhooks並且rake任務B未能刪除它們,我猜測允許任務A創建它們的權限不足以允許任務B刪除它們。雖然我能夠使用測試商店和控制檯創建/刪除,但很明顯,刪除Webhooks不再困惑我。好哇。 – 2012-08-11 00:15:58

2

當應用程序被卸載時,由應用程序創建的Webhooks(和ScriptTags)會自動刪除。看起來可能是這裏發生的事情。

如果你是在迴應app/uninstalled webhook,這是沒有理由的。它已經被處理了!

+0

嗯。不,沒有關係,但是的確如此,我可以卸載應用程序,是的,瞧,沒有更多的Webhooks。當然,這是愚蠢的......但是,儘管如此,當一個人絕望時仍然可行。 – 2012-08-01 03:39:32

2

如果刪除webhook連接的端點,它將在19次嘗試連接後終止。

從shopify文檔(http://wiki.shopify.com/WebHook#Automatic_Retries_and_Deletion)

如果返回一個錯誤或發送網絡掛接時發生超時, Shopify將重試請求同48小時使用指數 補償方法。共有19次嘗試提供 信息。

你也可以刪除該應用程序,它會刪除網絡掛接

+0

再次......這並沒有回答這個問題。如果創建一個webhook,然後想刪除它,它是如何被刪除的。目前,任何刪除webhook的努力都會產生錯誤。卸載應用程序或刪除端點是殘酷的。 – 2012-08-09 15:56:27