Hi,
I am trying to call https webservice with basic authentication request.
I tried using below code, but i am getting an error.
var request = WebRequest.Create(new Uri("intkgpdj.service.svc/CloseTask"));
request.Headers[System.Net.HttpRequestHeader.Authorization] = "Basic " +
Convert.ToBase64String(Encoding.ASCII.GetBytes(@"domain\username"+ password));
request.Method = "POST";
request.ContentType = "application/json";
string postData = @"
{
'TaskRequest':
[
{
'Field1': 'answerValue', 'Field2': 'value12', 'field3' : 'true', 'ApplicationData':[{ 'ApplicationId': 'value11', 'ApplicationKey': 'value12'}]
}
]
}";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentLength = byteArray.Length;
System.IO.Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
using (var response = request.GetResponse())
{
responseText = new StreamReader(response.GetResponseStream()).ReadToEnd();
}
Please help.
thanks
*This post is locked for comments