我有訪問REST API的守護進程的問題。RestClient基本身份驗證與#在用戶名
訪問需要基本認證。用戶名和密碼是固定的,不能更改。
這個問題似乎是,該用戶名看起來像這樣:#ws+R4nd0mS7r1n
我訪問這樣的API:
resource = RestClient::Resource.new("#{base_url}/failover/#{failover_ip}", { :user => user_name, :password => user_password})
response = resource.get
這讓我一個壞的URI錯誤:
bad URI(absolute but no path): https://#ws+R4nd0mS7r1n:[email protected]/failover/11.11.11.11
當我從它的工作用戶名中刪除#時,我得到一個NOT Authenticated錯誤。
有沒有辦法將包含#的用戶名或密碼傳遞給restclient? 將完整的URI手動傳遞給.get也不起作用。
你有沒有嘗試過其他客戶?像[法拉第](https://github.com/lostisland/faraday)或[HTTParty](https://github.com/jnunemaker/httparty/blob/master/examples/delicious.rb)? – 2013-03-22 10:22:30
您是否嘗試用'%23'替換'#'? – 2013-03-22 11:18:55
用戶名/密碼組合最終會進入http請求的Authorization頭部,因此Oto建議嘗試替代客戶端是合理的。此外,你可以嘗試直接設置標頭 – 2013-03-22 12:13:09