Friday, 13 July 2012

OData error and office add-in

Recently I was trying to use OData for one of our user requirements. I was following the post from Robin. Every thing was smooth until the moment I tried the URL to return the OData Query Service definition


Following error appeared
The server encountered an error processing the request. The exception message is 'Exception of type 'Microsoft.Dynamics.AX.Framework.Services.Metadata.Exceptions.MetadataItemException`1[Microsoft.Dynamics.AX.Framework.Services.Metadata.Contracts.FieldGroupMetadata]' was thrown.'. See server logs for more details. The exception stack trace is:
at Microsoft.Dynamics.AX.Framework.Services.ODataQueryService.ODataMetadataCache.get_Metadata() at Microsoft.Dynamics.AX.Framework.Services.ODataQueryService.ODataService`1.GetService(Type serviceType) at System.Data.Services.WebUtil.GetService[T](Object target) at System.Data.Services.DataService`1.CreateProvider() at System.Data.Services.DataService`1.HandleRequest() at System.Data.Services.DataService`1.ProcessRequestForMessage(Stream messageBody) at SyncInvokeProcessRequestForMessage(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
As the error states there is an issue with the field group metadata, but this does not explain what the error is, which table in the query has this error or how to resolve it. One of the tables in the query was CustTable and we have some modifications on this table. I then tried to read data from this table in Excel using office add-in and it threw the following error

Excel add-in was right on the spot in finding out the error that a field present in the field group does not actually exist in the table fields and the reference in field group was invalid (it was a custom field that during the upgrade was removed from the table but the was still present in the field group). Once that field was removed from the field group OData service was fine. Now what I really wonder is why one part of the application gives you meaningful error and not the other?

This posting is provided "AS IS" with no warranties. Use code at your own risk.

No comments:

Post a Comment