Issue #3952 resolved
Morten Andersen created an issue

This workds just fine:

{{{ curl -k --user myUsername:myPassword }}}

Same user/pass and uri from .NET fails:

{{{ WebRequest request = WebRequest.Create(""); request.Credentials = new NetworkCredential("myUsername", "myPassword"); WebResponse response = request.GetResponse(); }}}

WebException: The remote server returned an error: (401) Unauthorized.

Comments (4)

  1. Dylan Etkin

    Hi Morten,

    I am not sure about the framework you are using but with curl you are using basic auth. Do you need to tell you .Net web request to use basic?

    As you point out the endpoint is working just fine. I am not sure we are really qualified to help debug .Net code.



  2. Ondřej Vondra

    You must force basic http authentication:

    string authInfo = user + ":" + password; authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo)); request.Headers["Authorization"] = "Basic " + authInfo;

    Remove request.Credentials = ... line completely.

  3. Log in to comment