Jeff Fillegar
asked on
c# httpclient - send authentication with request
Hello Experts,
I need to pass username and password with my httpclient post. How can I do that?
I need to pass username and password with my httpclient post. How can I do that?
string username = "user";
string password="pw";
string theCall = string.Format(qryString, "xml", "dbo", m_QryName);
using (var client = new HttpClient(BaseUri))
{
// Serialize object to send to the service
HttpContent theContent = HttpContentExtensions.Create(param.ToXElement<string>());
// Send request and get response
using (HttpResponseMessage response = client.Post(theCall, theContent))
{
}
}
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.