I am creating a program that communicates with a webapi and is giving me this error in creating the header.
I'm using this to create the header:
var tempo = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
var httpWebRequest = (HttpWebRequest)WebRequest.Create("teste");
httpWebRequest.Headers.Add("Date"+ tempo);
The output is this:
Date2017-09-08T15: 25: 53Z
I wanted it to be this:
Date: 2017-09-08T15: 25: 53Z
I have also tested the following code:
httpWebRequest.Headers.Add($"Date: {DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ")}");
This code generated the following error:
System.ArgumentException: 'The' Date 'header must be modified with the proper property or method. '