2015-01-22 1 views
2

나는 웹 사이트 URL 요청시 Ruby Gem rest-client을 사용합니다. 다음 오류가 발생합니다 ...HTTP 오류 받기 RestClient :: Unauthorized (401 Unauthorized) : 레일에 'rest-client'gem 사용

RestClient::Unauthorized (401 Unauthorized): 
    app/controllers/api/v1/channels_controller.rb:199:in `streaming_link' 

도와주세요. 내가 인식 할 때까지 나는 또한 그것 때문에 서비스가 필요한 다이제스트 인증의 것을, 401을 나머지 클라이언트로 어려움을 겪고되었다

def streaming_link 
    url = URI.encode("http://eboundservices.com/hash/hash_app.php?code=orientplay") 
    result = RestClient::Request.new({:user => "hashapp", :password => "PlayFair00",:method => :post, :url => url}).execute 

    return render :json =>{:success=>true,:result=>result} 
end 

답변

2

내 컨트롤러 방법이 우는 소리입니다. Rest-Client currently did not support digest auth.

대신에 나는 httparty으로 바뀌 었습니다. 401과 동일 할 수도 있습니다.

@auth = {:username => 'hashapp', :password => 'PlayFair00'} 
options = { :digest_auth => @auth } 
response = HTTParty.get('http://eboundservices.com/hash/hash_app.php?code=orientplay', options) 
관련 문제