我使用RESTClient实现做一个POST请求和我做到了,所以我的错误响应回来,所以我可以在控制台如何访问这种散列
打印这些错误信息,我试图按照RESTClient实现宝石以下文档
begin
response = RestClient.post base_uri, params.to_json, content_type: 'application/json', accept: 'application/json'
rescue RestClient::ExceptionWithResponse => err
error = err.response
p "this is the error response #{error}"
end
当我打印err.response我得到以下
"this is the error response {\"error\":{\"message\":\"An active access token must be used to query information about the current us er.\",\"type\":\"OAuthException\",\"code\":2500,\"fbtrace_id\":\"HTzmJ0CcIfd\"}}"
我如何在上面的散列访问消息在控制台中显示它?
试图
p "this is the error response #{error.message}"
,这让我"Bad request"
- 不知道从哪里它获取
嘿感谢响应试过以上,但给我一个空字符串'“这是错误响应”'这是奇怪。尝试使用put和Rails.logger.debug –
我该如何检查? –
啊它说它是一个'string' –