2
I’m creating a communication with a web api and I needed to create a header date type but formatted to ISO 8601. What I want is to get the following output :
Date: 2017-09-13T08:21:08Z
My code is this::
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 got the following error :
System.Argumentexception: 'Date header has to be modified with the appropriate property or method.'
The form it has shown does not perform the output I want but this solution I have found performs the output I wanted, but thank you very much for your help
– Pedro Azevedo