3
votes

The Web API on error response includes stack trace and inner exception. Due to security reasons, we want to remove stack trace from error response.

May I know how to do these configurations?

This is existing sample error response:

{
  "error":{
    "code":"","message":"Resource not found for the segment '***_experienceses'.",
    "innererror":{
      "message":"Resource not found for the segment '***_experienceses'.",
      "type":"Microsoft.OData.Core.UriParser.ODataUnrecognizedPathException",
      "stacktrace":"at Microsoft.OData.Core.UriParser.Parsers.ODataPathParser.ParsePath(ICollection`1 segments)\r\n   at Microsoft.OData.Core.UriParser.Parsers.ODataPathFactory.BindPath(ICollection`1 segments, ODataUriParserConfiguration configuration)\r\n   at Microsoft.OData.Core.UriParser.ODataUriParser.Initialize()\r\n   at System.Web.OData.Routing.DefaultODataPathHandler.Parse(IEdmModel model, String serviceRoot, String odataPath, ODataUriResolverSetttings resolverSettings, Boolean enableUriTemplateParsing)\r\n   at System.Web.OData.Routing.DefaultODataPathHandler.Parse(IEdmModel model, String serviceRoot, String odataPath)\r\n   at Microsoft.Crm.Extensibility.OData.CrmODataPathHandler.Parse(IEdmModel model, String serviceRoot, String odataPath)"
    }
  }
}

We want to be like that:

{
  "error":{
     "code":"","message":"Resource not found for the segment '***_experienceses'."  
   }
}
2

2 Answers

0
votes

Stop CRM async service. Then start again and published all.

0
votes

I believe that this is NOT possible from within Dynamics 365. The web API documentation has no mention of being able to customize the content of error messages. They will always be delivered in the same format.

Microsoft Docs: Parse errors from the response

If you are really concerned about the stack trace being exposed you could created a custom web API that sits between D365 and whatever is consuming the D365 data. This wrapper API could strip out the data you are concerned about.

It's dirty but I don't think you have any other options...