在 Firebase 上调用带有消息正文的 GET

Calling a GET with a message body on Firebase

我正在尝试呼叫(来自 https://firebase.google.com/docs/cloud-messaging/ios/device-group

Retrieving a notification key
If you need to retrieve an existing notification key, use the notification_key_name in a GET request as shown:

https://fcm.googleapis.com/fcm/notification?notification_key_name=appUser-Chris Content-Type:application/json Authorization:key=API_KEY project_id:SENDER_ID {}

这看起来像是带有消息正文和内容类型 (!) 的 GET。如果我 POST 它我得到一个关于丢失 notification_key_name 的错误。如果我使用 HttpClient 获取它,它会抱怨它不是 JSON 请求,如果我通过执行以下操作强制它具有 Content-Type:

_client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");

它给了我同样的错误。如果我尝试使用 GET 请求发送消息正文“{}”,HttpClient 拒绝发送它。关于如何让它工作有什么想法吗?

我无法让 HttpClient 执行此操作,不得不求助于使用 HttpWebRequest..

var wr = (HttpWebRequest)WebRequest.Create("https://fcm.googleapis.com/fcm/notification?notification_key_name=" + name);
            wr.Method = "GET";
            wr.ContentType = "application/json";
            wr.Headers.Add("Authorization", "key=" + applicationID);
            wr.Headers.Add("project_id", senderId);

            var resp = await wr.GetResponseAsync();
            using (Stream stream = resp.GetResponseStream())
            {
                StreamReader reader = new StreamReader(stream, Encoding.UTF8);
                return reader.ReadToEnd();
            }