title: The remote server returned an error: "(405) Method Not Allowed"
body: <p>After reading different answers against the same thread i tried almost all the options mentioned in their discussions however i am still getting error:</p>
  
  <p><strong>Error No1</strong>: <em><code>The remote server returned an error: (404) Not Found.</code></em> OR</p>
  
  <p><strong>Error No2</strong>:<em><code>The remote server returned an error: (405) Method Not Allowed</code>.</em></p>
  
  <p>Below is my code:</p>
  
  <pre><code>var httpWebRequest = (HttpWebRequest)WebRequest.Create("URL?Paramter1=pc&amp;user=u1&amp;password=p1");
  httpWebRequest.ContentType = "application/json; charset=utf-8";
  httpWebRequest.Method = "POST";
  httpWebRequest.Accept = "application/json";
  var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
  </code></pre>
  
  <p>I receive error on the last line i.e. </p>
  
  <pre><code>var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
  </code></pre>
  
  <p>If i use <code>httpWebRequest.Method="GET"</code> i receive the error number 1 as mentioned above and if i use <code>httpWebRequest.Method="Post"</code> i receive the error number 2. </p>