I am trying to post a request to a REST service (HP ALM 11 REST API fwiw) using rest-client and keep getting the Unauthorized response. Could be I am not following the docs right but also I am not sure I am doing the headers properly. So far my googling for RestClient has been fruitless. Any help would be appreciated:
Code:
@alm_url = "http://alm_url/qcbin/"
@user_name = "username"
@user_password = "password"
authentication_url = @alm_url + "rest/is-authenticate"
resource = RestClient::Resource.new authentication_url
resource.head :Authorization => Base64.encode64(@user_name) + ":" + Base64.encode64(@user_password)
response = resource.get
#response = RestClient.get authentication_url, :authorization => @username, @user_password
Rails.logger.debug response.inspect
Based on this SO question I also tried the following without success:
@alm_url = "http://alm_url/qcbin/"
@user_name = "username"
@user_password = "password"
authentication_url = @alm_url + "rest/is-authenticate"
resource = RestClient::Resource.new authentication_url, {:user => @user_name, :password => @user_password}
response = resource.get
#response = RestClient.get authentication_url, :authorization => @username, @user_password
Rails.logger.debug response.inspect
Documentation:
Client sends a valid Basic Authentication header to the authentication point.
GET /qcbin/authentication-point/authenticate Authorization: Basic ABCDE123
Server validates the Basic authentication headers, creates a new LW-SSO token and returns it as LWSSO_COOKIE_KEY.