Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think you need to make two changes;</p> <p>(a) Use the rails routing to tag this as an XML request (b) Use HTTP Basic Authentication to authenticate the request.</p> <p>This means changing your URL above to include the username, password like this</p> <p>me:secret@localhost:3000/foos/1.xml</p> <p>also note .xml bit</p> <p>I guess that somewhere on your server-side you have code that authenticates in-bound requests via a before filter. This needs to work something like this ...</p> <pre><code># # If you haven't authenticated already then you are either # reqirected to the logon screen (for HTML formats) or # the browser prompts you. You are always allowed to pass # the username/password in the URL # def login_required @current_user = valid_session? unless @current_user if params["format"] # # If you specify a format you must authenticate now # do_basic_authentication else display_logon_screen end end end # # Ask Rails for the login and password then authenticate as if this # were a new login. # def do_basic_authentication user = authenticate_with_http_basic do |login, password| User.authenticate(login, password) end if user current_user(@current_user = user) else request_http_basic_authentication end end </code></pre> <p>That's from our own app and is triggered by a before_filter in ApplicationController.</p> <p>Also, I don't think you need the :content_type => 'application/xml'. What I normally do is just call post or put directly like this ..</p> <p>response = RestClient.post URI.encode(url), :record => args</p> <p>where the url contains the basic authentication and the ".xml"</p> <p>Happy coding</p> <p>Chris</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload