次のコードがあり、投稿リクエストの承認を次のように設定したいと思います。
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();
}
}
}
これを行う方法?私は本当に苦労しており、次の声明
client.DefaultRequestHeaders.Add("Authorization", "key=" + apiKey);
次の例外をスローしました
タイプ 'System.FormatException' の例外が System.Net.Http.dll で発生しましたが、ユーザー コードで処理されませんでした