I am trying to invoke service which is expecting RFC 1123 formatted date in the Request header using C#.
I using the bellow code:-
var req = WebRequest.Create(loginDdsLink) as HttpWebRequest;
req.PreAuthenticate = true;
req.Method = "POST";
req.Accept = "*/*";
req.ContentType = "application/json";
req.ReadWriteTimeout = 100000;
req.Headers.Add(HttpRequestHeader.Date, Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(dt.ToUniversalTime().ToString("R"))));
The last line is throwing exception because HttpRequestHeader.Date is expecting DateTime but i am passing String. Is there any way to send the String value in the HttpRequestHeader.Date parameter?