I am creating a communication with a web api and I needed to create a header of type date but formatted to ISO 8601 . What I want is to get the following output:
Date: 2017-09-13T08: 21: 08Z
My code is as follows:
var tempo = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
var httpWebRequest = (HttpWebRequest)WebRequest.Create("test.com");
What I've already tried:
httpWebRequest.Headers.Add("Date", tempo);
httpWebRequest.Headers.Add($"Date: {DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ")}");
httpWebRequest.Headers["Date"] = tempo;
With these codes I get the following error:
System.ArgumentException: 'The' Date 'header must be modified with the proper property or method. '