title: HTTP Post method is not working for yammer api
body: <p>I need to implement a service for sending invitation mail to users.
  I am following <a href="https://samlman.wordpress.com/2015/03/02/using-the-yammer-api-in-a-net-client-application/" rel="nofollow noreferrer">Samlman's artice</a>.
  I am trying to get a permanent token for Yammer API using the post method shown below.</p>
  
  <p>I'm currently getting:</p>
  
  <blockquote>
    <p>Error: 404 "server not found error".</p>
  </blockquote>
  
  <p>There is no inner exception.</p>
  
  <p>Do I need to pass <code>authHeader</code>?</p>
  
  <p>If yes, then how do I send the <code>authHeader</code>?</p>
  
  <pre><code>string authUrl1 = string.Format("https://www.yammer.com/session?client_id={0}" , CLIENT_ID);
  string postBody = string.Format(
          "{0}{1}{2}{3}{4}{5}{6}",
          "utf8=%E2%9C%93&amp;authenticity_token=",
          System.Web.HttpUtility.UrlEncode(authToken),
          "&amp;network_permalink=&amp;login=",
          HttpUtility.UrlEncode(userName),
          "&amp;password=",
          pwd,
          "&amp;remember_me=off");
  
  //make the first post for code
  postResults = MakePostRequest(postBody, authUrl1);
  private static string MakePostRequest(string postBody, string url, string authHeader = null, string contentType = null)
  {
      string results = string.Empty;
  
      try
      {
          //get the session and yamtrack cookie
          SetCookies();
  
          wr = WebRequest.CreateHttp(url);
          wr.Method = "POST";
          wr.CookieContainer = cc;
  
          //if an authHeader was provided, add it as a Bearer token to the request
          if (!string.IsNullOrEmpty(authHeader))
              wr.Headers.Add("Authorization", "Bearer " + authHeader);
  
          byte[] postByte = Encoding.UTF8.GetBytes(postBody);
  
          if (string.IsNullOrEmpty(contentType))
              wr.ContentType = "application/x-www-form-urlencoded";
          else
              wr.ContentType = contentType;
  
          wr.ContentLength = postByte.Length;
          Stream postStream = wr.GetRequestStream();
          postStream.Write(postByte, 0, postByte.Length);
          postStream.Close();
  
          wResp = (HttpWebResponse)wr.GetResponse();
          postStream = wResp.GetResponseStream();
          StreamReader postReader = new StreamReader(postStream);
  
          results = postReader.ReadToEnd();
  
          postReader.Close();
          postStream.Close();
      }
      catch (Exception ex)
      {
          Console.WriteLine("Error in MakePostRequest: " + ex.Message);
      }
      return results;
  }
  </code></pre>