Method Not Allowed Error 405 Web Api
Contents |
here for a quick overview of the site Help Center Detailed 405 method not allowed web api put answers to any questions you might have Meta Discuss the 405 method not allowed web api delete workings and policies of this site About Us Learn more about Stack Overflow the company 405 method not allowed web api angularjs Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join 405 method not allowed put the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Web API Put Request generates an Http 405 Method Not Allowed error up vote 80 down vote favorite 27 Here's the
405 Method Not Allowed Iis
call to the PUT method on my Web API - the third line in the method (I am calling the Web API from an ASP.NET MVC front end): client.BaseAddress is http://localhost/CallCOPAPI/. Here's contactUri: Here's contactUri.PathAndQuery: And finally, here's my 405 response: Here's the WebApi.config in my Web API project: public static void Register(HttpConfiguration config) { config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); config.Routes.MapHttpRoute( name: "DefaultApiGet", routeTemplate: "api/{controller}/{action}/{regionId}", defaults: new { action = "Get" }, constraints: new { httpMethod = new HttpMethodConstraint("GET") }); var json = config.Formatters.JsonFormatter; json.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects; config.Formatters.Remove(config.Formatters.XmlFormatter); I've tried stripping down the path that gets passed into PutAsJsonAsync to string.Format("/api/department/{0}", department.Id) and string.Format("http://localhost/CallCOPAPI/api/department/{0}", department.Id) with no luck. Does anyone have any ideas why I'm getting the 405 error? UPDATE As per request, here's my Department controller code (I will post both the Department controller code for my
Websites Community Support ASP.NET Community Standup ForumsHelp Web API:Guidance Videos Samples Forum Books Open Source Testing
405 Method Not Allowed Web Api Options
and Debugging Getting StartedGetting Started with Web API 2 (C#)Getting 405 method not allowed post Started with ASP.NET Web APICreating a Leaderboard App with Azure Mobile Services .NET BackendAction Results in 405 (method not allowed) angularjs Web API 2Web API 2 PosterPro ASP.NET Web APIUsing Web API with ASP.NET Web FormsCreating Web API Help PagesHands On Lab: Build a Single Page http://stackoverflow.com/questions/19162825/web-api-put-request-generates-an-http-405-method-not-allowed-error Application (SPA) with ASP.NET Web API and Angular.jsRoutingRouting in Web APIRouting and Action Selection in Web APIAttribute Routing in Web API 2Create a REST API with Attribute Routing in Web API 2Working with DataUsing Web API 2 with Entity Framework 61. Create the Project2. Add Models and Controllers3. Seed the Database4. https://www.asp.net/web-api/overview/testing-and-debugging/troubleshooting-http-405-errors-after-publishing-web-api-applications Handling Entity Relations5. Create Data Transfer Objects (DTOs)6. Create the JavaScript Client7. Create the View (UI)8. Display Item Details9. Add a New Item to the Database10. Publish the App to Azure WebsitesASP.NET Data Access - Recommended ResourcesMobile ClientsCalling Web API from a Windows Phone 8 Application (C#)Get Started with Mobile Apps in Azure App ServiceCreating a Leaderboard App with Azure Mobile Services .NET BackendAdd Authentication to your Mobile AppAdd Push Notifications to Your Mobile AppODataOData v4Create an OData v4 EndpointCreate an OData v4 Client App (C#)Entity Relations in OData v4Actions and Functions in OData v4Containment in OData v4Create a Singleton in OData v4Open Types in OData v4Complex Type Inheritance in OData v4OData v3Creating an OData v3 EndpointSupporting Entity Relations in OData v3OData Actions in Web API 2Calling an OData Service From a .NET Client (C#)A New Option for Creating OData: Web APISupporting OData Query Options in Web API 2Using $select, $expand, a
Windows Communication Foundation, Serialization, and Networking Question 0 https://social.msdn.microsoft.com/Forums/vstudio/en-US/021258d5-9878-4395-8a1b-c10ddcf66e31/405-method-not-allowed-in-web-api-controller?forum=wcf Sign in to vote I am using a web api controller. [HttpPost] public HttpResponseMessage Change(int id) {} routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } );Why is it that I am getting the 405 errorwhen the url is http://localhost/api/Storage Changed type Otomii Lu Thursday, method not September 13, 2012 3:07 AM Tuesday, September 11, 2012 4:09 PM Reply | Quote Answers 1 Sign in to vote Hi, I'm not familiar with web api, and I've found a similiar link for you: http://stackoverflow.com/questions/9854602/asp-net-web-api-405-http-verb-used-to-access-this-page-is-not-allowed-how Hope helpful. And I suggest you to refer to the web api method not allowed forums directly where more experts on web api will help you: http://forums.asp.net/1246.aspx/1?ASP+NET+Web+API Marked as answer by Otomii Lu Tuesday, September 25, 2012 6:11 AM Thursday, September 13, 2012 3:07 AM Reply | Quote Microsoft is conducting an online survey to understand your opinion of the Msdn Web site. If you choose to participate, the online survey will be presented to you when you leave the Msdn Web site.Would you like to participate? Privacy statement Dev Centers Windows Office More... Related Sites Visual Studio Visual Studio Integrate VSIP Program Microsoft .NET Microsoft Azure Connect Forums Blog Facebook LinkedIn Stack Overflow Twitter Visual Studio Events YouTube Developer Resources Code samples Documentation Downloads Products & extensions for Visual Studio REST APIs Testing tools for web developers Videos and tutorials Virtual Labs United States (English) © 2016 Microsoft Terms of Use Trademarks Privacy Statement Site Feedback