title: AngularJS $http.POST method 405 error
body: <p>In $http.post method I'm getting 405 issue. We are using single service(REST) for both POST &amp; GET methods. </p>
  
  <p>if url having localhost it is working. urlAddScenario is localhost/Service.svc/api/scenarios/add. If I'm using machine name instead of locahost it is not working. machinname/Service.svc/api/scenarios/add </p>
  
  <p>My JS code is</p>
  
  <pre><code> scenarioExecutionFactory.addScenario = function (scenarioId) {
          return $http.post(urlAddScenario, scenarioId)               
      };
  </code></pre>
  
  <p>anotherJS:</p>
  
  <pre><code> var runScenarioId = { "ScenarioId": 10 }
                     scenarioExecutionFactory.addScenario(runScenarioId )
                           .success(function (data) {
                               $scope.getScenarioRecentRuns($scope.CurrentScenario);
                           });
  </code></pre>
  
  <p>WCF Service: </p>
  
  <pre><code>  [OperationContract]
          [WebInvoke(UriTemplate = "api/scenarios/add",
              RequestFormat = WebMessageFormat.Json,
              ResponseFormat = WebMessageFormat.Json,
              Method = "POST")]
          Request AddScenario(ScenarioRequestParams requestParams);
  </code></pre>
  
  <p>config:</p>
  
  <pre><code>   &lt;system.webServer&gt;
  &lt;httpProtocol&gt;
    &lt;customHeaders&gt;
      &lt;add name="Access-Control-Allow-Origin" value="*" /&gt;
      &lt;add name="Access-Control-Allow-Credentials" value="true" /&gt;
      &lt;add name="Access-Control-Allow-Methods" value="GET,POST,PUT,OPTIONS" /&gt;
      &lt;add name="Access-Control-Allow-Headers" value="Origin,Content-Type,Accept,Authorization,X-Ellucian-Media-Type" /&gt;
    &lt;/customHeaders&gt;
  
  &lt;/httpProtocol&gt;
  </code></pre>
  
  <p></p>
  
  <p>I'm seeing OPTIONS instead of POST in Headers.</p>
  
  <p>Headers:</p>
  
  <pre><code>**OPTIONS** http://ddd/HelloService/HelloService.svc/PostData HTTP/1.1
  Accept: */*
  Origin: http://localhost:31284
  Access-Control-Request-Method: POST
  Access-Control-Request-Headers: accept, content-type
  Accept-Encoding: gzip, deflate
  User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; Touch; rv:11.0) like Gecko
  Host: vijayakatta
  Content-Length: 0
  DNT: 1
  Connection: Keep-Alive
  Pragma: no-cache
  </code></pre>
  
  <p>Error:</p>
  
  <p>IE: SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.</p>
  
  <p>Chrome: XMLHttpRequest cannot load htp//machinename/services.svc/api/scenarios/add. Invalid HTTP status code 405</p>
  
  <p>Response Headers: HTTP/1.1 405 Method Not Allowed</p>