Resolving Http 405 – Method not Allowed

I have an API App named the StorageConnector. After adding a new method named CheckIfAGABeoordeling, I suddenly got a Http 405 – Method Not Allowed error on another methode in the StorageConnector, being DeleteAGABijlage.

I first tried to add a Http Header Allow when calling DeleteAGABijlage, but that didn’t work:
Header Allow: DELETE

Next I started searching on the Internet and found it could potentially be a routing issue. Below are the relevant method signatures and a snippet from the webapi.config:

public static class WebApiConfig
public static void Register(HttpConfiguration config)
// Web API configuration and services
config.Formatters.Insert(0, new TextMediaTypeFormatter());

// Web API routes

name: “DefaultApi”,
routeTemplate: “api/{controller}/{action}/{id}”,
defaults: new { id = RouteParameter.Optional }

[SwaggerOperation(“GetObjectData”)] [HttpGet] //[ActionName(“GetObjectData”)] [Route(“api/Storage/{objectName}/{objectId}”)] public HttpResponseMessage GetObjectData(string objectName, string objectId)

[SwaggerOperation(“CheckIfAGABeoordeling”)] [HttpGet] //[ActionName(“CheckIfAGABeoordeling”)] [Route(“api/Storage/{errorMessage}”)] public HttpResponseMessage CheckIfAGABeoordeling(string errorMessage)

[SwaggerOperation(“DeleteAGABijlage”)] [HttpDelete] [ActionName(“DeleteAGABijlage”)] //[Route(“api/Storage/AGABijlage/{integrationId}”)] public HttpResponseMessage DeleteAGABijlage(string integrationId, string documentId, string formCode)

A Http 405 error can be caused by a routing issue.

As you can see, it’s quite a mess. Sometimes routes are taken from the webapi.config, sometimes routes are taken from the method signature. Also, the routing template in the webapi.config is not very pretty. Take for example the variable {action}, which does in fact not refer to the ActionName. Confusing. Anyhow, I tried different things, like adding the action name to CheckIfAGABeoordeling, but I couldn’t get it to work. I was also a bit afraid to make changes to solve this particular issue and then create other issues.

So, what I did next, is change the method CheckIfAGABeoordeling to a private method. I renamed the method to ResumeAfterFailure. Next I called the method from GetObjectData.

private bool ResumeAfterFailure(string context, string errorMessage)

public HttpResponseMessage GetObjectData(string objectName, string objectId)

switch (objectName)
case “AGABeoordeling”:
bool result = ResumeAfterFailure(objectName, objectId);
if (result)
response = this.Request.CreateResponse(HttpStatusCode.OK);
response = this.Request.CreateResponse(HttpStatusCode.InternalServerError);

I now made the following call from my Logic App:

Unfortunately I received a Http 404 error this time: The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. I opened a browser and entered the address to get the same result. Than I started experimenting a bit and found out that the error message after AGABeoordeling contained ‘.’ and ‘:’. Those characters caused the issue. After adding replace functions to my logic app, I finally received successful calls.


A Http 404 error can be caused by invalid characters in your URL like . or :