RE: Dynamics 365 API View response createdBy value return userId instead of userName
Hi Michel and Aric,
Thanks for helping again. I tried the approach you and Aric proposed.
In the request header, I added
retrieveRequest.Headers.Add("Prefer", "odata.include-annotations=OData.Community.Display.V1.FormattedValue");
When construct my response object, I did a small test of
if (attributeName.Equals("_createdby_value"))
{
var temp = dataEntry["_createdby_value@OData.Community.Display.V1.FormattedValue"];
}
-------------------------------------------------------------------------------------------------------------------------------------
But above gave me error of "HttpMessageInvoker.cs not found: error when tracing through it, and in the final response gives
{
Message: "An error has occurred.",
ExceptionMessage: "The given key was not present in the dictionary.",
ExceptionType: "System.Collections.Generic.KeyNotFoundException",
StackTrace: " at System.Web.Http.ApiController.<InvokeActionWithExceptionFilters>d__1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__0.MoveNext()"
}
Do you spot anyplace I missed please? Thanks again.