title: Simple HTTP Post Requests with ASP.NET MVC
body: <p>I want to consume a Google API within my web application. Specifically, I want to use Firebase to send Push-Messages to mobile devices.</p>
  
  <p>I tried using Advanced REST Client for testing the functionality. When I configure it like this:</p>
  
  <p><a href="https://i.stack.imgur.com/Lx9dV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lx9dV.png" alt="Request configured in a testing client"></a></p>
  
  <p>I get "200 OK" and the push message is displayed on the smartphone.</p>
  
  <p>I tried implementing this in Visual Studio now:</p>
  
  <pre><code>        HttpClient client = new HttpClient();
  
          HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, "https://fcm.googleapis.com/fcm/send");
          requestMessage.Headers.Add("Content-Type", "application/json");
          requestMessage.Headers.Add("Authorization", "key=AAAAG...:APA91bH7U...");
          requestMessage.Content = new StringContent("{ \"notification\": { \"title\": \"Portugal vs. Denmark\", \"body\": \"5 to 1\"  }, \"to\": \"caJ_lIocLY4:APA91bEL19TRFFPlXFx3kZ_FTt...Q\" }");
  
  HttpResponseMessage response = client.SendAsync(requestMessage).GetAwaiter().GetResult();
  </code></pre>
  
  <p>But get Exceptions like System.InvalidOperationException on the first requestMessage.Headers.Add line. The Message of the Exception is (roughly translated) "Wrongly used Headername. Make sure, that Requesetheaders are usedi with "HttpRequestMessage"-Objects, Answerheaders with "HttpREsponseMessage"-Objects[...].</p>
  
  <p>For me, what I'm doing there is a POST Message. I'm calling the service and I need to pass arguments. So for me this is a request with arguments.</p>
  
  <p>What do I need to do here?</p>