I have the following code, and I want to set up mail request authorization this way:
Authorization:key=somevalue
using (HttpClient client = new HttpClient()) { using (StringContent jsonContent = new StringContent(json)) { jsonContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); using (HttpResponseMessage response = await client.PostAsync("https://android.googleapis.com/gcm/send", jsonContent)) { var reponseString = await response.Content.ReadAsStringAsync(); } } }
how to do it? I am really struggling and the following statement
client.DefaultRequestHeaders.Add("Authorization", "key=" + apiKey);
the following exception is thrown
An exception of type "System.FormatException" occurred in System.Net.Http.dll, but was not processed in user code
source share