lloydom
lloydom

Reputation: 387

WCF REST Invoke with POST throws Error

I have my interface defined as

[OperationContract]
[WebInvoke(Method = "PostUserData", BodyStyle = 
            WebMessageBodyStyle.WrappedRequest)]
string GetWine2(string wineID);

and service behaviour as

public string GetWine2(string wineID)
{
    return "I love this type of : " + wineID;
}

when i use the wfetch tool to post the data i consistently get a 405 error from IIS. This lead me to think it is some problem on IIS. I have tried making a POST call from a custom code and there too i get the same error. I read on this forum where people had problems because of WebDav, but i dont think i have it installed, would be great if some one can point to me if this is installed, i have no idea what is WebDav. What could be the other reason on IIS 7.5 to block post calls?

I placed a dummy ASPX page and that serves out fine.

Upvotes: 0

Views: 103

Answers (1)

Parthi
Parthi

Reputation: 46

Method should be "POST" ...Change webinvoke like this

 [WebInvoke(Method = "POST")] 

or

 [WebInvoke(Method = "POST", UriTemplate = "/GetWine2/{wineID}" BodyStyle = 
        WebMessageBodyStyle.WrappedRequest)]  

or

 [WebInvoke(Method = "POST", UriTemplate = "/GetWine2/{wineID}") ] 

What is the URL are you using to invoke this method?

Upvotes: 1

Related Questions