Hi Friends,
I am trying to consume the new Dynamics AX7 OData endpoint from a .Net console applications, I can see that the authentication is going fine but whenever I try to get the results on my application it ends with an Unauthorized error. Any idea on what could be the cause or hos to get a more detailed information (logs)?
This is the code that throws the error at line,
static void Main(string[] args)
{
Uri oDataUri = new Uri(ODataEntityPath, UriKind.Absolute);
var context = new Resources(oDataUri);
context.SendingRequest2 += new EventHandler<SendingRequest2EventArgs>(delegate (object sender, SendingRequest2EventArgs e)
{
var authenticationHeader = OAuthHelper.GetAuthenticationHeader();
e.RequestMessage.SetHeader(OAuthHelper.OAuthHeader,
authenticationHeader);
});
foreach (var legalEntity in context.LegalEntities.AsEnumerable())
{
Console.WriteLine("Name:{0}", legalEntity.Name);
}
Expection occurs like :
An unhandled exception of type
'Microsoft.OData.Client.DataServiceQueryException' occurred in
Microsoft.OData.Client.dll
Additional information: An error occurred while processing this request.
My Cilent Configuration is like :
public static CilentConfiguration OneBox = new CilentConfiguration()
{
UriString = "usnconeboxax1aos.cloud.onebox.dynamics.com",
UserName = "***",
Password = "pass***",
ActiveDirectoryResource =
"usnconeboxax1aos.cloud.onebox.dynamics.com",
ActiveDirectoryTenant =
"login.windows.net/.../authorize",
ActiveDirectoryClientAppId = "cb5c660e-ad09-4895-90a0-778786cdf956",
ActiveDirectoryClientAppSecret =
"lMLjJm0tCgUGvUs6LJtzWscKTpJZBMgkCng7es2BDkY=",
and my error page is ,
![]()
![]()
![]()
I dont know where error ocuurs, can anyone suggest me an answer.
Thanks & regards,
padmapriya