如何获得 API 呼叫 (shopify) 的响应?

How to get the responses of an API call (shopify)?

我已经使用 rails 大约一个星期了,找到了许多很好的教程,但没有找到任何关于我当前问题的信息。 我有一个网店 运行 并且可以通过 shopify 控制台访问它:

      ShopifyAPI::Customer.find(674469828)
      -> will return the customer with the id 674469828

如果我在我的 rails 应用程序中使用相同的代码,则不会发生任何事情。我想获得此 API 调用的错误消息,但不知道如何执行此操作。我的意思是我正在向服务发送 POST 请求并收到响应(例如 HTTP/1.1 200 OK)。
我如何 "catch" 我的代码中的 http 响应?如何显示响应 header?我可以使用简单的 http 请求并轻松获得响应,但如果有 API,为什么不使用它。
如果有任何帮助,我将不胜感激。

假设您已使用 API 凭据等设置您的应用程序,您可以 "catch" 通过将响应分配给变量来 "catch" 响应,如下所示:

customer = ShopifyAPI::Customer.find(674469828)
# now we can play around with the customer object

customer.name # => "Jimmy" 

如果这没有帮助/没有抓住要点,请 post 一个特定的错误消息或服务器输出,表明您正在接受您提出的特定请求。