0

Tried Code:

var request = WebRequest.Create("http://localhost/RestfulTutorialService/Service.svc/Post"); request.Method = "PUT"; request.ContentType = "application/json"; using (var writer = new StreamWriter(request.GetRequestStream())) { var serializer = new JavaScriptSerializer(); var payload = serializer.Serialize(objBlogPost); writer.Write(payload); } var response = (HttpWebResponse)request.GetResponse(); var responseCode = response.StatusCode; 

Error:The remote server returned an error: (405) Method Not Allowed.

My service is a Restful service. Below is the method being called.

 [OperationContract] [WebInvoke(Method = "PUT", UriTemplate = "/Post", RequestFormat = WebMessageFormat.Json)] void UpdateBlogPost(BlogPost post); 
4
  • use postman or other tool to check where you're wrong. Commented Sep 30, 2016 at 17:06
  • @Div using post worked for me. Is any change required in iis to allow put requests? Commented Sep 30, 2016 at 17:36
  • Add X-HTTP-Method-Override: PUT Read here may this helps you! Commented Sep 30, 2016 at 17:46
  • Possible duplicate of WCF error : 405 Method Not Allowed Commented Sep 30, 2016 at 21:54

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.