【发布时间】:2015-08-06 16:22:00
【问题描述】:
我目前正在尝试在 HTTParty 中发送一个获取请求,该请求会登录并获取一些 API 数据。我通过 curl 成功地做到了这一点:
curl -v --user USERNAMEHERE:PassWordHere http://app.ionitnetworks.com/ionit-app/api/rest/v1/devices
这在我的控制台中输出:
➜ HeatWatch git:(kunzig_new_heatwatch) ✗ curl -v --user (userOmitted):(password_omitted) http://app.ionitnetworks.com/ionit-app/api/rest/v1/devices
* Hostname was NOT found in DNS cache
* Trying 23.92.23.58...
* Connected to app.ionitnetworks.com (23.92.23.58) port 80 (#0)
* Server auth using Basic with user 'userOmitted'
> GET /ionit-app/api/rest/v1/devices HTTP/1.1
> Authorization: Basic ZG91Z0dofW301320Y2AsayZlLmNvbTpkb3VnMTIz
> User-Agent: curl/7.35.0
> Host: app.ionitnetworks.com
> Accept: */*
我已经尝试了很多东西来让它在 httparty 中工作,但没有任何工作,例如:
@response = HTTParty.post("https://app.ionitnetworks.com/ionit-app/api/rest/v1/devices.json", :headers =>{ "Authorization" =>"Token token=\"AccountsTokenOmitted\"" })
任何提示将不胜感激!
【问题讨论】:
标签: ruby-on-rails-3 curl httparty