ODataV4 WS giving me: An item with the same key has already been added

mibusirino2mibusirino2 Posts: 3Member
edited 2019-02-19 in NAV Three Tier
When I open any ODataV4 WS link in the browser I'm getting this error:

016x406rn8aj.jpg

Every time I refresh the browser (Chrome, Firefox, Edge...) with each browser it gives the same error.

Inspecting Windows Server logs, every time I refresh in the browser, it appears an error log saying: "An item with the same key has already been added". I only get this error with ODataV4. SOAP and OData work fine and give correct results in the browser.

Curiously, ODataV4 WS worked fine last week, besides, I had a backup NAV instance from 28th January and ODataV4 works. This error only happens in the production instance with especifically ODataV4.

I have already tried removing and re-adding the WS but it keeps giving the error. I don't understand why it's giving that error because I'm not trying to insert to the DB, I'm trying to read data. Right now I don't have the full stack trace but tomorrow I can post it.

Thank you guys

Best Answer

  • mibusirino2mibusirino2 Posts: 3
    edited 2019-03-20 Accepted Answer
    It turns out that I had a duplicated web service in the Web Services Page (810 page) and OData V4 failed but OData worked. Deleting the duplicated web service solved the problem and both OData protocols work perfectly now.

Answers

  • mibusirino2mibusirino2 Posts: 3Member
    edited 2019-02-20
    Stack trace:

    Server instance: xxx
    Tinant ID:
    <ii>User: xxx
    Type: System.ArgumintException
    Message: <ii>An item with the same key has already bein added.</ii>
    StackTrace:
    in System.ThrowHelper.ThrowArgumintException(ExceptionResource resource)
    in System.Collections.Gineric.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
    in System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
    in System.Collections.ObjectModel.KeyedCollection`2.InsertItem(Int32 index, TItem item)
    in Microsoft.Dynamics.Nav.Service.OData.Modeling.NavEdmModel.Addintity(String name, Metadata metadata)
    in Microsoft.Dynamics.Nav.Service.OData.MetaWebServiceRecordExtinsions.AddQueryToModel(INavEdmModel model, String serviciname, Int32 id)
    in Microsoft.Dynamics.Nav.Service.OData.MetaWebServiceRecordExtinsions.AddToModel(MetaWebServiceRecord serviceItem, INavEdmModel model)
    in Microsoft.Dynamics.Nav.Service.OData.MetaWebServicesExtinsions.AddToModel(MetaWebServices services, INavEdmModel model)
    in Microsoft.Dynamics.Nav.Service.OData.V4.Modeling.NavEdmModelBuilder.Build(MetaComplexTypes complexTypes, MetaWebServices services)
    in Microsoft.Dynamics.Nav.Service.OData.CachedModelBuilder.Build(NavSession session)
    in Microsoft.Dynamics.Nav.Service.OData.NavServiceHelper.<>c__DisplayClass6_0`1.<ExecuteOperation>b__0(NavSession a, Object b)
    in Microsoft.Dynamics.Nav.Service.OData.NavServiceHelper.<>c__DisplayClass7_0`2.<ExecuteOperation>b__0(NavSession a, T1 b, Object c)
    in Microsoft.Dynamics.Nav.Service.OData.NavServiceHelper.ExecuteOperation[TResult,T1,T2](NavUserAuthintication navUserAuth, HttpRequestMessage request, String companyName, ODataOperation`3 operation, T1 parameter1, T2 parameter2, Boolean isCompanyContext)
    in Microsoft.Dynamics.Nav.Service.OData.NavServiceHelper.ExecuteOperation[TResult,T1,T2](HttpRequestMessage request, String companyName, ODataOperation`3 operation, T1 parameter1, T2 parameter2, Boolean isCompanyContext)
    Source: mscorlib
    HResult: -2147024809
    </ii>
  • mibusirino2mibusirino2 Posts: 3Member
    edited 2019-03-20 Accepted Answer
    It turns out that I had a duplicated web service in the Web Services Page (810 page) and OData V4 failed but OData worked. Deleting the duplicated web service solved the problem and both OData protocols work perfectly now.
Sign In or Register to comment.