Wednesday, February 17, 2016

Mysterious HTTP 405 Status Code from Azure API App

Currently we are working on a project that uses the beta version of Azure Logic App and API App technologies.

One of the tasks is to build a Test Driver to call an HTTP Listener API App on Azure to trigger the Logic App workflow using the .net HttpClient object.

We have completed the test driver last week. Everything was working fine on Dev & QA environment.

Then comes the deployment to UAT environment. Today all of a sudden one of my colleagues told me that the test driver is not working on UAT environment. Instead of getting the usual status code 200 (OK) or 400 (Bad Request), our test driver is getting a 405 (Method Not Allowed) error, with an empty response content.

We followed the typical check to ensure that the HTTP Method is correct. We even use Fiddler and Postman to call the HTTP Listener API App, which works as expected.

We tried various things such as redeploy the HTTP Listener, or redeploy the test driver app, and still no luck.

We also tried to have the test driver to call another API App, somehow that works fine. The only one that failed is when calling the UAT HTTP Listener.

This is a mystery, since usually when there's anything wrong on the server side, we got a 500 error, and that we can enable tracing to see what's going on with the server. For this one, we simply got nothing. No error, no log, nothing.

After almost 1 hour of tweaking the code, playing with various config, we notice that the call to the problematic HTTP Listener API App is using non-secure HTTP (http://....), whereas on dev & QA we have secured HTTPS protocol.

Updating the config endpoint to use HTTPS for the HTTP Listener API App. BINGO! It returns a 200 (OK) status code as expected.

Apparently, the Azure API App requires a secure connection. Using the non-secure HTTP protocol will result in a 405 (Method Not Allowed) status. This response comes from the API App Host, so we got nothing in the trace log since it has been rejected before it even reach the API App.

A lesson learned.

No comments:

Post a Comment