Error handling in API Management

I’m having an issue in API Management. The problem is that I only get a 500 Internal Server Error. Question is: Do I use the correct backend Url? Can I get a more elaborate error description? The answer is: Yes. I found an excellent document on the Azure website: Check it out. Here you can read that you can add an on-error scope in your policy editor. In the on-error policy, you can add eventhub logging or return a reponse with more detailed information. In order to get detail information you need to know about policy expressions and especially the context object. An excellent link can be found here: Check it out. Here is the on-error section of my policy expression:

<forward-request follow-redirects=”false” />
<log-to-eventhub logger-id=”loghuapimtest” partition-id=”0″>
@(string.Join(“;”, DateTime.UtcNow.ToString(“dd-MM-yyyy hh:mm:ss.FFF”),
“ApimUrl”, context.Request.OriginalUrl, “BackendUrl”, context.Request.Url,
“ErrorMsg”, context.LastError.Message, “ErrorScope”, context.LastError.Scope, “ErrorSection”, context.LastError.Section))
<set-status code=”500″ reason=”API Management Error” />
@{ string inBody = context.LastError.Message;
inBody = inBody + ” (” + context.LastError.Reason + “)”;
inBody = inBody + “\n” + “APIM Url: ” + context.Request.OriginalUrl;
inBody = inBody + “\n” + “Backend Url: ” + context.Request.Url;
return inBody; }

Now I’m getting a response in the Developer Portal that makes sense:

Unable to connect to the remote server (BackendConnectionFailure)
Backend Url: