【问题标题】:How to view the X-Shopify-Shop-Api-Call-Limit如何查看X-Shopify-Shop-Api-Call-Limit
【发布时间】:2023-01-19 05:19:21
【问题描述】:

我想查看这个特定的标题:X_SHOPIFY_SHOP_API_CALL_LIMIT

当我这样做时:

  CreateShopifyClientService.call(shop)
  begin
    response = ShopifyAPI::InventoryLevel.find(:all, params: { inventory_item_ids: product.inventory_item_id})
    byebug
  rescue Exception => e
    byebug
  end

我已经尝试了几乎所有我能想到的方法,包括查看 gem 上的测试但找不到神秘的标头。

以下是我的一些徒劳的尝试:

    (byebug) ap response.header
*** NoMethodError Exception: undefined method "header' for #<ShopifyAPI::PaginatedCollection:0x000055b39213c9c8>

(byebug) ap response.headers
*** NoMethodError Exception: undefined method "headers' for #<ShopifyAPI::PaginatedCollection:0x000055b39213c9c8>

【问题讨论】:

    标签: ruby shopify shopify-api


    【解决方案1】:

    我刚刚在我的终端机上做了这个,它工作了一个桃子......

    shop = Shop.first
    session = ShopifyAPI::Auth::Session.new(
     shop: shop.shopify_domain,
     access_token: shop.shopify_token
    )
    client = ShopifyAPI::Clients::Rest::Admin.new(
     session: session
    )
    
    response = client.get(path: "products")
    p response.headers["x-shopify-shop-api-call-limit"]
    ["1/40"]
    => ["1/40"]
    

    所以访问响应头并不太难。我看到您得到的是 API 调用的响应,而不是 HTTP 响应本身,因此对于那些旧的 API 调用,您似乎需要采用不同的方法。也许尝试更新到更现代的 API,看看是否对您有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-27
      • 1970-01-01
      • 2013-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-14
      相关资源
      最近更新 更多