如何在WebRequest中添加标题。
HttpWebRequest tRequest = (HttpWebRequest)WebRequest.Create("https://fcm.googleapis.com/fcm/send");
tRequest.Method = "POST";
tRequest.ContentType = "application/json";
var data = new
{
to = devicesId,
notification = new
{
body = "Fcm Test Notification",
title = "Test FCM",
sound = "Enabled"
},
priority = "high"
};
tRequest.Headers["Authorization: key={0}"] = appId;
tRequest.Headers["Sender: id={0}"] = senderId;
我需要添加标题来创建Web请求。
谢谢
答案 0 :(得分:0)
Add
中遗失HttpWebRequest
是因为CoreFx中缺少ISerializable
(因此您不能简单地tRequest.Headers.Add("name", "value");
)。他们正在努力,您可以在https://github.com/dotnet/corefx/issues/12669