Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在Firebase上使用消息体调用GET_C#_Firebase_Google Cloud Messaging_Httpclient - Fatal编程技术网

C# 在Firebase上使用消息体调用GET

C# 在Firebase上使用消息体调用GET,c#,firebase,google-cloud-messaging,httpclient,C#,Firebase,Google Cloud Messaging,Httpclient,我正试着打电话(从) 检索通知密钥 如果需要检索现有通知密钥,请在GET请求中使用通知密钥名称,如图所示: https://fcm.googleapis.com/fcm/notification?notification_key_name=appUser-克里斯 内容类型:application/json授权:key=API\u key 项目\u id:发件人\u id {} 它看起来像一个带有消息正文和内容类型(!)的GET。如果我发布它,我会得到一个关于缺少通知\u密钥\u名称的错误。如果我

我正试着打电话(从)

检索通知密钥
如果需要检索现有通知密钥,请在GET请求中使用通知密钥名称,如图所示:

https://fcm.googleapis.com/fcm/notification?notification_key_name=appUser-克里斯
内容类型:application/json授权:key=API\u key
项目\u id:发件人\u id
{}

它看起来像一个带有消息正文和内容类型(!)的GET。如果我发布它,我会得到一个关于缺少通知\u密钥\u名称的错误。如果我使用HttpClient获取它,它会抱怨它不是JSON请求,如果我通过执行以下操作强制它具有内容类型:

\u client.DefaultRequestHeaders.TryAddWithoutValidation(“内容类型”、“应用程序/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();
            }