title: 405 Method not allowed error in WCF web service Post Method
body: <p>I am using WCF web service and getting the error "405 Method not allowed" while calling POST method from browser but it is working fine from PostMan. 
  Here is my code for WCF POST method </p>
  
  <pre><code>    [OperationContract]
      [WebInvoke(UriTemplate = "pushData", 
                 Method = "POST", 
                 ResponseFormat = WebMessageFormat.Json,
                 RequestFormat = WebMessageFormat.Json, 
                 BodyStyle = WebMessageBodyStyle.Bare)]
      bool pushDataForReporting(PushDataWrapUp data);
  </code></pre>
  
  <p>This this is my web.config </p>
  
  <pre><code>   &lt;system.web&gt;
        &lt;webServices&gt;
           &lt;protocols&gt;
              &lt;add name="HttpSoap" /&gt;
              &lt;add name="HttpPost" /&gt;
              &lt;add name="HttpGet" /&gt;
              &lt;add name="Documentation" /&gt;
              &lt;add name="HttpPostLocalhost" /&gt;
           &lt;/protocols&gt;
        &lt;/webServices&gt;
        &lt;compilation targetFramework="4.5" debug="true" /&gt;
        &lt;httpRuntime targetFramework="4.5" /&gt;
     &lt;/system.web&gt;
     &lt;system.serviceModel&gt;
        &lt;standardEndpoints&gt;
           &lt;webScriptEndpoint&gt;
              &lt;standardEndpoint name="" crossDomainScriptAccessEnabled="true" /&gt;
           &lt;/webScriptEndpoint&gt;
        &lt;/standardEndpoints&gt;
        &lt;services&gt;
           &lt;service name="WrapUpWebService.WrapUp" behaviorConfiguration="ServiceBehaviour"&gt;
              &lt;endpoint address="" binding="webHttpBinding" contract="WrapUpWebService.IWrapUp" behaviorConfiguration="web" /&gt;
           &lt;/service&gt;
        &lt;/services&gt;
        &lt;behaviors&gt;
           &lt;serviceBehaviors&gt;
              &lt;behavior name="ServiceBehaviour"&gt;
                 &lt;!-- To avoid disclosing metadata information, set the values below to false before deployment --&gt;
                 &lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /&gt;
                 &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt;
              &lt;/behavior&gt;
           &lt;/serviceBehaviors&gt;
           &lt;endpointBehaviors&gt;
              &lt;behavior name="web"&gt;
                 &lt;webHttp /&gt;
              &lt;/behavior&gt;
           &lt;/endpointBehaviors&gt;
        &lt;/behaviors&gt;
        &lt;!--&lt;protocolMapping&gt;
          &lt;add binding="basicHttpsBinding" scheme="https" /&gt;
          &lt;/protocolMapping&gt;--&gt;
        &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /&gt;
        &lt;bindings&gt;
           &lt;webHttpBinding&gt;
              &lt;binding name="jsonpWebHttpBinding" crossDomainScriptAccessEnabled="true" /&gt;
           &lt;/webHttpBinding&gt;
        &lt;/bindings&gt;
     &lt;/system.serviceModel&gt;
     &lt;system.webServer&gt;
        &lt;modules runAllManagedModulesForAllRequests="true" /&gt;
        &lt;httpProtocol&gt;
           &lt;customHeaders&gt;
              &lt;add name="Access-Control-Allow-Origin" value="*" /&gt;
              &lt;add name="Access-Control-Allow-Headers" value="Content-Type, Accept" /&gt;
              &lt;add name="Access-Control-Allow-Methods" value="GET, POST, OPTIONS" /&gt;
              &lt;add name="Access-Control-Max-Age" value="1728000" /&gt;
           &lt;/customHeaders&gt;
        &lt;/httpProtocol&gt;
        &lt;directoryBrowse enabled="true" /&gt;
     &lt;/system.webServer&gt;
  </code></pre>
  
  <p>This my Javascript code</p>
  
  <pre><code>var settings = {
  "async": true,
  "crossDomain": true,
  "url": "http://localhost/WrapUpWebService/WrapUp.svc/pushData",
  "method": "POST",
  "headers": {
  "content-type": "application/json;charset=utf-8",
  "cache-control": "no-cache",
  "postman-token": "946a48f2-ae43-4595-62b2-0d9856bd4187"
  },
    "processData": false,
    "data": "{\"AgentId\": \"12345\",\"RouterCallKey\":    \"Testing\",\"RouterCallKeyDay\":\"223344\", \"SkillGroupSkillTargetId\":\"12356\",\"SkillGroup\":\"BB\",\"DNIS\" : \"111\",\"ANI\":\"123456\",\"SelectedWrapUpCode\" :\"Testing &amp; testing\"}"
  }
  
   $.ajax(settings).done(function (response) {
   console.log(response);
  });
  </code></pre>
  
  <p>browser response 
  <a href="https://i.stack.imgur.com/lT7bF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lT7bF.jpg" alt="enter image description here"></a></p>
  
  <p>Postman Response 
  <a href="https://i.stack.imgur.com/kzCyJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kzCyJ.jpg" alt="enter image description here"></a></p>