OData Annotations do not appear when not localhost

45 Views Asked by At

I'm building an OData response by throwing a standard HttpResponseException. The exception itself is built with an HttpResponseMessage based on ODataError.

  new ODataError()
            {
                ErrorCode = code,
                Message = message,
                InnerError = new ODataInnerError()
                {
                    Message = innerException.Message,
                    StackTrace = innerException.StackTrace,
                    TypeName = innerException.GetType().Name
                },
                InstanceAnnotations = annotations
            });

The result rendered is correct when making the request on localhost.

However, Annotations are not rendered when the request is not made on the same server, is there a way to configure this behaviour?

Note: the nuget package currently used is Microsoft.OData.Core 6.12.0

1

There are 1 best solutions below

0
On BEST ANSWER

Maybe it helps to set the config.IncludeErrorDetailPolicy to always. It is default set to IncludeErrorDetailPolicy.LocalOnly:

public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            // ...

            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
        }
    }