I am using Refit on my Xamarin client app.
When I call my Api and there are ModelState/Validation errors I return a ValidationProblem(ModelState)
to my client. Refit then throws a ValidationApiException
. In the exception there is a traceId.
How can I get the traceId
on the server side so I can log it?
I would like to be able to correlate client device logs with the server when there are bugs/problems.
The source shows that the
traceId
property is retrieved like this:If you want to get hold of this inside a controller, you can use this like so:
Note that
httpContext
changed toHttpContext
, which is a property ofControllerBase
. If you want to access this outside of a controller, you might need to useIHttpContextAccessor
instead.