0

How to add the header in the 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; 

i need to add the header to create the web Request.

Thanks

1 Answers1

0

Missing Add in HttpWebRequest is because have missing ISerializable in CoreFx (so you can not simply tRequest.Headers.Add("name", "value");). They working on it and you can follow at https://github.com/dotnet/corefx/issues/12669

J. Doe
  • 2,651
  • 1
  • 13
  • 31