wcf service returns "method not allowed" error

I'm trying to pass object parameter as json format to wcf restful service.

service conratc code like this;

    Method = "POST",
    BodyStyle = WebMessageBodyStyle.Wrapped,
    ResponseFormat = WebMessageFormat.Json,
    RequestFormat = WebMessageFormat.Json,
TWorkRequestPostResult PostRequest(TWorkRequestPostArgs args);

And my web.config file like this;

          <!-- To avoid disclosing metadata information, set the value below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true" />
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="WebDAVModule"/>
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
    <directoryBrowse enabled="true" />

When I trying call the service with "http://localhost/serviceurl/PR" url, Service returned "Method not allowed" error message.


Are you calling the service from the browser? If so, the browser requests the service using HTTP GET while the service method is mapped to HTTP POST, Method = "POST", thus resulting in the error "Method not allowed".

To fix, either change to Method = "GET" if it makes sense with regards to REST or try calling the service method from a tool that supports POST, e.g. Fiddler or WcfTestClient

Need Your Help

Use Storyboard to mask UIView and give rounded corners?

ios xcode swift storyboard autolayout

Lots of questions like this explain how to programmatically create a mask and provide rounded corners to a UIView.

What to know before starting to learn JavaFX?

java javafx

I read about the advantages of JavaFX over Swing(that is not the point of discussion) and I would like to learn JavaFX.