2016-12-01 4 views
0

WebRequestにヘッダーを追加する方法。コードheader.addが.netコアで機能していない

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; 

ウェブリクエストを作成するためにヘッダーを追加する必要があります。

おかげCoreFxでISerializableが欠落しているので、HttpWebRequestAddがある行方不明

+0

それはすでに複写されてここに答えます。 [HttpWebRequestでカスタムヘッダーを追加](http://stackoverflow.com/a/37430845/2337983) – Ahmar

+0

[HttpWebRequestでカスタムヘッダーを追加]の可能な複製(http://stackoverflow.com/questions/8519788/add-custom -header-in-httpwebrequest) –

+0

重複していない、私の答えを読む –

答えて

関連する問題