Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Niels Kristiansen 166 posts 382 karma points
    Feb 15, 2011 @ 23:04
    Niels Kristiansen
    0

    Password protected feed in XSLT

    Hi,

    I try to get information from a partner that had protected the feed with username and password. Unfortuantly, when I try to catch the feed, I get the following error:

    System.Net.WebException: The remote server returned an error: (401) Unauthorized. at System.Net.HttpWebRequest.GetResponse() at umbraco.library.GetXmlDocumentByUrl(String Url)

    I have placed a following link into my xslt: http://username:[email protected]/feed?f=username&categories=x

    Like this:

    <xsl:variable name="feed" select="umbraco.library:GetXmlDocumentByUrl('http://username:[email protected]/feed?f=username&amp;categories=x')"/>

    When I try it directly in a browser no problem what so ever, but why do I get the 401 when tried in XSLT. What am I doing wrong here?

     

    Kind regards,

    Niels

  • Niels Kristiansen 166 posts 382 karma points
    Feb 17, 2011 @ 22:18
    Niels Kristiansen
    0

    No one here that can help me out?

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    Feb 17, 2011 @ 22:32
    Jan Skovgaard
    0

    Hi Niels

    Is it when you save the XSLT file you get the error? Or do I misunderstand your post?

    /Jan

  • Niels Kristiansen 166 posts 382 karma points
    Feb 17, 2011 @ 23:03
    Niels Kristiansen
    0

    Hi Jan,

    Thanks for your reply.

    No, it's working fine, when I save the XSLT file. The problem is when I try to render it up in the frontend environment. It's here I get my error.

    It's like it don't get the username and password, that's needed to bring out the information from the xml. The XML itself it's placed on an external webpage, but you can connect to it if you just go write the url directly in the browsers.

    /Niels

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Feb 18, 2011 @ 18:43
    Chriztian Steinmeier
    0

    Hi Niels,

    I'm guessing it's something internally in the GetXmlDocumentByUrl() function that somehow doesn't send the URL correct...

    Maybe it's possible for you to put a password-protected page up somewhere that you could try to connect to and see what's sent from Umbraco? 

    /Chriztian 

  • Niels Kristiansen 166 posts 382 karma points
    Feb 22, 2011 @ 23:59
    Niels Kristiansen
    0

    Hi Chriztian,

    I think that too, but I don't how to set up a password-protected page to test if it's there the problem is with GetXmlDocumentByUrl(). Is there any alternatives for this, so I can catch the XML in another way?

    BTW, sorry for the delayed answer...

     

    /Niels

  • Niels Kristiansen 166 posts 382 karma points
    Mar 30, 2011 @ 10:16
    Niels Kristiansen
    0

    Hi Chriztian,

    Could you help me out on this one. I don't think I understood your solution for the missing GetXmlDocumentByUrl() not picking up the username and password for a password protected Feed.

     

    Kind regards

    Niels

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Mar 30, 2011 @ 23:08
    Chriztian Steinmeier
    1

    Hi Niels,

    I've just tried this on a file behind a username+password - I can't see what Umbraco is sending, but it seems to not handle this scenario correct. The error suggests that the server's initial response of 401 actually means "401 Authorization Required", and that Umbraco somehow never performs the second request.

    Here's a rundown of what's involved from a HTTP perspective - this was performed with http://hurl.it - pasting a URL with username + password.

    You can see there's actually two requests (the first two GET sections) with each their responses...

    GET /protected/movies.xml HTTP/1.1
    Host: www.testsection.com
    Accept: */*
    
    
    GET /protected/movies.xml HTTP/1.1
    Authorization: Basic ZGVzbW9uZDo0ODE1MTYyMzQy
    Host: www.testsection.com
    Accept: */*
    
    
    HTTP/1.1 401 Authorization Required
    Date: Wed, 30 Mar 2011 20:59:55 GMT
    Server: Apache
    WWW-Authenticate: Basic realm="The Hatch"
    Vary: Accept-Encoding
    Content-Length: 520
    Content-Type: text/html; charset=iso-8859-1
    
    HTTP/1.1 200 OK
    Date: Wed, 30 Mar 2011 20:59:55 GMT
    Server: Apache
    Last-Modified: Wed, 30 Mar 2011 20:42:58 GMT
    ETag: "bc22005-11c-49fb938d39880"
    Accept-Ranges: bytes
    Content-Length: 284
    Content-Type: application/xml
    
    
    <?xml version='1.0' encoding='UTF-8'?> 
    <movies>
      <movie>
        <title>
          Star Wars Episode IV: A New Hope
        </title>
      </movie>
      <movie>
        <title>
          Star Wars Episode V: The Empire Strikes Back
        </title>
      </movie>
      <movie>
        <title>
          Star Wars Episode VI: Return Of The Jedi
        </title>
      </movie>
    </movies>

    So guess you could file a bug about this?

    /Chriztian

  • jivan thapa 194 posts 681 karma points
    Mar 31, 2011 @ 00:09
    jivan thapa
    0

    Have you try by escaping special characters like "//,?" ?

  • Becky 5 posts 25 karma points
    Jan 30, 2012 @ 18:14
    Becky
    0

    I'm also having this problem, I'm trying to make it fail gracefully though rather than actually go into the password protected feed.
    Does anyone have any ideas? I've tried the following but it just never gets into the when, sits there until it times out, have also tried with $feedContent != 'error' with no luck!

    <xsl:variable name="feedContent" select="umbraco.library:GetXmlDocumentByUrl($feed, $cacheRate)"/>
              <xsl:choose>
                <xsl:when test="count($feedContent/error) &gt; 0">
  • Simon Dingley 1431 posts 3332 karma points c-trib
    Jan 24, 2013 @ 14:06
    Simon Dingley
    0

    I am having this same issue on a site I have inherited and recently upgraded to Umbraco 4.11.3. I've taken a quick look at the Umbraco Core and I think that this is down to a permissions problem due to the context under which the request is made I think.

  • Simon Dingley 1431 posts 3332 karma points c-trib
    Jan 24, 2013 @ 15:22
    Simon Dingley
    0

    Not sure if it helps or not but I've worked out why this is happening in my situation. The staging site I was working on has basic authentication enabled, the request is made under a different context to that which I am using to browse the site and therefore is denied access without the authentication credentials.

    I hope this might help.

    Simon

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies