Lucky
Lucky

Reputation: 21

Error: Method not allowed in REST wcf Api

I have written an API with this format:

[OperationContract]
[WebInvoke(Method = "Get", UriTemplate = "/GetPrice/{ItemID}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
string GetVegatablePrice(string ItemID);

I got an error:

method not allowed

Upvotes: 1

Views: 62

Answers (1)

Lucky
Lucky

Reputation: 21

Finally I got answer for this.

Solution

Just change method name to "GET".

While writing an Http method, make sure to write in uppercase, like:

  • "GET"
  • "PUT"
  • "POST"
  • "DELETE"

Upvotes: 1

Related Questions