Http 401 Unauthorised

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Iain Adams

    Http 401 Unauthorised

    I currently have a web service set that returns data. When I use these
    services through a browser, everything works fine and the resulting xml
    is displayed. However sometimes when I connect to the scripts using a
    php script I get the error message Http 401: Unauthorised. This usually
    happens after a short time, when the webservices have not been used. I
    am connecting to the webservices using Http Post and cURL.

  • Iain Adams

    #2
    Re: Http 401 Unauthorised

    In Addition the actual error message is

    A SoapException occurred: Message: The request failed with HTTP status
    401: Unauthorized. Exception: System.Net.WebE xception: The request
    failed with HTTP status 401: Unauthorized.
    at
    System.Web.Serv ices.Protocols. SoapHttpClientP rotocol.ReadRes ponse(SoapClien tMessage
    message, WebResponse response, Stream responseStream, Boolean
    asyncCall)
    at
    System.Web.Serv ices.Protocols. SoapHttpClientP rotocol.Invoke( String
    methodName, Object[] parameters)
    at CRMWebService.C RMWebService.Cr mService.Execut e(Request Request)
    in \\MYCOMPUTER\\w wwroot\CRMWebSe rvice\Web
    References\CRMW ebService\Refer ence.cs:line 48
    at CRMWebService.G etMultipleEntit ies.GetData(Str ing[] fieldsToGet)
    in \\mycomputer\\w wwroot\crmwebse rvice\getmultip leentities.cs:l ine 48

    the Code this error refers to is actually Visual C# but is pretty
    normal.


    I just cant work out why sometimes it works and sometimes not


    Iain Adams wrote:
    I currently have a web service set that returns data. When I use these
    services through a browser, everything works fine and the resulting xml
    is displayed. However sometimes when I connect to the scripts using a
    php script I get the error message Http 401: Unauthorised. This usually
    happens after a short time, when the webservices have not been used. I
    am connecting to the webservices using Http Post and cURL.

    Comment

    • Jerry Stuckle

      #3
      Re: Http 401 Unauthorised

      Iain Adams wrote:
      In Addition the actual error message is
      >
      A SoapException occurred: Message: The request failed with HTTP status
      401: Unauthorized. Exception: System.Net.WebE xception: The request
      failed with HTTP status 401: Unauthorized.
      at
      System.Web.Serv ices.Protocols. SoapHttpClientP rotocol.ReadRes ponse(SoapClien tMessage
      message, WebResponse response, Stream responseStream, Boolean
      asyncCall)
      at
      System.Web.Serv ices.Protocols. SoapHttpClientP rotocol.Invoke( String
      methodName, Object[] parameters)
      at CRMWebService.C RMWebService.Cr mService.Execut e(Request Request)
      in \\MYCOMPUTER\\w wwroot\CRMWebSe rvice\Web
      References\CRMW ebService\Refer ence.cs:line 48
      at CRMWebService.G etMultipleEntit ies.GetData(Str ing[] fieldsToGet)
      in \\mycomputer\\w wwroot\crmwebse rvice\getmultip leentities.cs:l ine 48
      >
      the Code this error refers to is actually Visual C# but is pretty
      normal.
      >
      >
      I just cant work out why sometimes it works and sometimes not
      >
      >
      Iain Adams wrote:
      >
      >>I currently have a web service set that returns data. When I use these
      >>services through a browser, everything works fine and the resulting xml
      >>is displayed. However sometimes when I connect to the scripts using a
      >>php script I get the error message Http 401: Unauthorised. This usually
      >>happens after a short time, when the webservices have not been used. I
      >>am connecting to the webservices using Http Post and cURL.
      >
      >
      Evidently the resource you're trying to access requires authorization.
      The 401 is a normal message from the server requesting your userid and
      password.

      Browsers handle this automatically. If this is the first 401 this site
      has sent while the browser has been running, it will pop up the
      userid/password box on your screen. It remembers this information for
      the specific site, and on the next 401 sends it automatically (if it is
      rejected this time, the browser pops the userid/password box again).

      I don't know how the remote site tracks this information. Some do it
      with sessions, some by tracking the remote ip, etc. And most have a
      timeout involved.

      If you've already retrieved some information, chances are the
      authorization has timed out and the system wants to reauthorize you.
      Check out the curl option CURLOPT_USERPWD .

      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      Working...