title: Ionic push notification api in c#
body: <p>So based on Tom Raz post <a href="https://stackoverflow.com/questions/33653934/ionic-push-notification-api-in-c-sharp-with-webapi">Ionic push notification api in c# with WebApi</a>. I tried to implement a method to send a push notification using the ionic push notifications api here is my code:</p>
  
  <pre><code>    public void sendToIonic(string regId, string msg) {
  
          using (var client = new HttpClient())
          {
              string data = "{ \"user_ids\":[\" "+ regId + "\"],\"notification\":{\"alert\":\" "+ msg + "\"}}";
  
              string json = Newtonsoft.Json.JsonConvert.SerializeObject(data);
  
              client.BaseAddress = new Uri("https://push.ionic.io/api/v1/push");
              client.DefaultRequestHeaders.Accept.Clear();
              client.DefaultRequestHeaders.Add("X-Ionic-Application-Id", "1d74b1f2");
              var keyBase64 = "Basic %s" + "53a03dc7d9ce58511263e40580294f62af36b89be7cc4db2";
              client.DefaultRequestHeaders.Add("Authorization", keyBase64);
              HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://push.ionic.io/api/v1/push");
  
              request.Content = new StringContent(data, Encoding.UTF8, "application/json");
              var response = client.SendAsync(request).Result;
          }
  
      }
  </code></pre>
  
  <p>But I keep getting the response <code>error 403 Forbidden;</code>. This is the complete response: </p>
  
  <blockquote>
    <p>{StatusCode: 403, ReasonPhrase: 'Forbidden', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
    {
      Connection: keep-alive
      Access-Control-Allow-Origin: *
      Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
      Date: Fri, 15 Jan 2016 20:50:33 GMT
      ETag: W/"35-nGlZv/eC8CyS+KJzQ1P9rg"
      Server: Cowboy
      Via: 1.1 vegur
      X-Powered-By: Express
      Content-Length: 53
      Content-Type: application/json; charset=utf-8
    }}</p>
  </blockquote>
  
  <p>Not sure what is wrong. I am stuck. Any help would be appreciated.</p>