From: Engine Yard Date: 2009-07-28T14:50:10+09:00 Subject: Re: Posting an XML document to a protected API I actually have many HTTP GET API calls of the same format, they are all based on ActiveResource models Eg: response = User.find(:one, :from => "#{BACKEND_HOST_PATH}/users/#{session[:user_id]}/get_preferences.xml", :params => {:session_key => session[:session_key]}) and the User model defines self.site as: self.site = "http://#{BACKEND_API_KEY}@#{BACKEND_HOST_AND_PORT}" so I am pretty sure that the http://APIKEY@DOMAIN_NAME:PORT_NUMBER/PATH_TO_RESOURCE.RESPONSE_FORMAT/?PARAM_NAME=PARAM_VALUE works fine. The main reason I am not using this pattern to make the POST call is: The xml content that is contained the POST message's body is a little complex. Is there anyother way I can make a POST to the API. 7stud -- wrote: > 7stud -- wrote: >> 7stud -- wrote: >>> 7stud -- wrote: >>>> The first thing I would do is try to get a response from the server >>>> without all the variables in your request string. To begin with, you >>>> need a valid API key and a valid session key. Then you can try >>>> something like this: >>>> >>> >>> I lied. That's not the first thing I would try. The first thing I >>> would try is posting your url into your browser's address bar to see if >>> you get a response. >> >> If that didn't work, then I would start looking for the specs on valid >> host names. >> >> ---- >> Restrictions on valid host names >> >> Hostnames are composed of series of labels concatenated with dots, as >> are all domain names[1]. For example, "en.wikipedia.org" is a hostname. >> Each label must be between 1 and 63 characters long, and the entire >> hostname has a maximum of 255 characters. >> >> RFCs mandate that a hostname's labels may contain only the ASCII letters >> 'a' through 'z' (case-insensitive), the digits '0' through '9', and the >> hyphen. Hostname labels cannot begin or end with a hyphen. No other >> symbols, punctuation characters, or blank spaces are permitted. >> ------ > > Then I would determine that this format is a mistake: > >>the URL should be of the format: > >>http://#{API_KEY}@#{BACKEND_HOST}:#{BACKEND_PORT}/#{PATH_TO_RESOURCE}?>session_key=#{SESSION_KEY} > > and I would try the following instead: > > http://#{BACKEND_HOST}:#{BACKEND_PORT}/#{API_KEY}@#{BACKEND_HOST}:#{BACKEND_PORT}#{PATH_TO_RESOURCE}?session_key=#{SESSION_KEY} > > or some variation thereof. -- Posted via http://www.ruby-forum.com/.