Question: I want to request reports from a third party and they require "Basic Access Authentication" via POST:

> 
> 
> ```
> Your client application must use Basic Access Authentication 
> to send the user name and password.
> 
> ```
> 
> 

Can someone point me in the right direction?

Edit: I did see [this post](https://stackoverflow.com/questions/450380/login-to-the-page-with-httpwebrequest/595318#595318) but there are two answers and I'm not sure if thats what I need to do or which one is the preferred method.

Answer: 
Assuming you use a WebRequest, you attach a CredentialCache to your request:

```
        NetworkCredential nc = new NetworkCredential("user", "password");
        CredentialCache cc = new CredentialCache();
        cc.Add("www.site.com", 443, "Basic", nc);

        WebRequest request = WebRequest.Create("https://www.site.com");
        request.Credentials = cc;
        request.PreAuthenticate = true;
        request.Method = "POST";

        // fill in other request properties here, like content

        WebResponse respose = request.GetResponse();

```
The basic gist is like this:

```
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Method = WebRequestMethods.Http.Get;
request.Credentials = new NetworkCredential(username, password);

```

but sometimes there are issues with using request credentials, the alternative is add the authentication data in request headers

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

```

for more details see this blog post

<http://charlie.cu.cc/2012/05/how-use-basic-http-authentication-c-web-request/>