title: firebase cloud messging to multiple users with C# server
body: <p>I am trying to send FCM notifications to multiple phones at once with my c# server.  I can send messages to one phone at a time with the following code,</p>
  
  <pre><code> try
          {
              var applicationID = "xAxxxxxxxxxxxxxxxxxxxx6g9vOeEmw1njaivVfIx";
              var senderId = "x7xxxxxxxxxxx5x";
              string deviceId = pushToken;
              WebRequest tRequest = WebRequest.Create("https://fcm.googleapis.com/fcm/send");
              tRequest.Method = "post";
              tRequest.ContentType = "application/json";
              var msg2send = new
              {
                  to = deviceId,
                  notification = new
                  {
                      body = msg,
                      title = "My Car Wash App",
                      icon = "myicon"
                  },
                  data = new
                  {
                      priority = 10,
                      notice = msg
                  }
              };
  
          var serializer = new JavaScriptSerializer();
          var json = serializer.Serialize(msg2send);
  
           Response.Write(json);
  
          Byte[] byteArray = Encoding.UTF8.GetBytes(json);
          tRequest.Headers.Add(string.Format("Authorization: key={0}", applicationID));
          tRequest.Headers.Add(string.Format("Sender: id={0}", senderId));
          tRequest.ContentLength = byteArray.Length;
  
          using (Stream dataStream = tRequest.GetRequestStream())
          {
              dataStream.Write(byteArray, 0, byteArray.Length);
  
              using (WebResponse tResponse = tRequest.GetResponse())
              {
                  using (Stream dataStreamResponse = tResponse.GetResponseStream())
                  {
                      using (StreamReader tReader = new StreamReader(dataStreamResponse))
                      {
                          string sResponseFromServer = tReader.ReadToEnd();
                          Response.Write(sResponseFromServer);
                      }
                  }
              }
          }
      }
  
      catch (Exception ex)
      {
          Response.Write(ex.Message);
      }
  </code></pre>
  
  <p>that works perfectly but I loop through my tokens and call that method over and over making hundreds of requests and that's not good</p>
  
  <p>I am trying to send a multi cast message as I can just pass in an array with all the tokens but I keep on getting bad request</p>
  
  <pre><code>var msg2send = new
              {
                  registration_ids = "[id1, id2]",
                  notification = new
                  {
                      body = msg,
                      title = "My Car Wash App",
                      icon = "myicon"
                  },
                  data = new
                  {
                      priority = 10,
                      notice = msg
                  }
              };
  </code></pre>
  
  <p>I am positive that registration_ids is a correct array with valid tokens when I send my request.  I am not sure what I am doing wrong.  Any help or suggestions would really be greatly appreciated.</p>