0

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?

Leventix
  • 3,789
  • 1
  • 32
  • 41
  • RFC 1123 mandates a base64 encoded version of the date? o_O – Mathias R. Jessen Feb 27 '16 at 18:14
  • no,if I try with bellow code then also getting same issue. req.Headers.Add(HttpRequestHeader.Date, dt.ToUniversalTime().ToString("R")); I tried the bellow too, but getting compiler error. req.Date = dt.ToUniversalTime().ToString("R"); – k kumar Feb 28 '16 at 02:46

0 Answers0