Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

API OData query through Exception - The type 'BadAmbiguousElementBinding:.' does not inherit from and is not a base type of 'BadAmbiguousElementBinding:.'. The type of 'KeySegments' must be related to the Type of the EntitySet.

(0) ShareShare
ReportReport
Posted on by 12

Hello,

When executes API get query from Javascript returns exception .

Following is the sample query:

http://domainname/xxxx/api/data/v8.0/sub_entityName(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)?$select=_sub_FieldName_value

Exception: 

{ "error":{ "code":"","message":"The type 'BadAmbiguousElementBinding:.' does not inherit from and is not a base type of 'BadAmbiguousElementBinding:.'. The type of 'KeySegments' must be related to the Type of the EntitySet.", "innererror":{ "message": "The type 'BadAmbiguousElementBinding:.' does not inherit from and is not a base type of 'BadAmbiguousElementBinding:.'. The type of 'KeySegments' must be related to the Type of the EntitySet.", "type":"Microsoft.OData.Core.ODataException","stacktrace":" at Microsoft.OData.Core.UriParser.ExceptionUtil.ThrowIfTypesUnrelated(IEdmType type, IEdmType secondType, String segmentName)\r\n at Microsoft.OData.Core.UriParser.Semantic.KeySegment..ctor(IEnumerable`1 keys, IEdmEntityType edmType, IEdmNavigationSource navigationSource)\r\n at Microsoft.OData.Core.UriParser.Parsers.SegmentKeyHandler.CreateKeySegment(ODataPathSegment segment, KeySegment previousKeySegment, SegmentArgumentParser key, ODataUriResolver resolver)\r\n at Microsoft.OData.Core.UriParser.Parsers.SegmentKeyHandler.TryCreateKeySegmentFromParentheses(ODataPathSegment previous, KeySegment previousKeySegment, String parenthesisExpression, ODataPathSegment& keySegment, Boolean enableUriTemplateParsing, ODataUriResolver resolver)\r\n at Microsoft.OData.Core.UriParser.Parsers.ODataPathParser.TryBindKeyFromParentheses(String parenthesesSection)\r\n at Microsoft.OData.Core.UriParser.Parsers.ODataPathParser.TryCreateSegmentForNavigationSource(String identifier, String parenthesisExpression)\r\n at Microsoft.OData.Core.UriParser.Parsers.ODataPathParser.CreateFirstSegment(String segmentText)\r\n at Microsoft.OData.Core.UriParser.Parsers.ODataPathParser.ParsePath(ICollection`1 segments)\r\n at Microsoft.OData.Core.UriParser.Parsers.ODataPathFactory.BindPath(ICollection`1 segments, ODataUriParserConfiguration configuration)\r\n at Microsoft.OData.Core.UriParser.ODataUriParser.Initialize()\r\n at System.Web.OData.Routing.DefaultODataPathHandler.Parse(IEdmModel model, String serviceRoot, String odataPath, ODataUriResolverSetttings resolverSettings, Boolean enableUriTemplateParsing)\r\n at System.Web.OData.Routing.DefaultODataPathHandler.Parse(IEdmModel model, String serviceRoot, String odataPath)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataPathHandler.Parse(IEdmModel model, String serviceRoot, String odataPath)" } } }


Kindly suggest any solution . Any kind of help will be appreciable.

Thank you. 

*This post is locked for comments

  • Community Member Profile Picture
    on at
    RE: API OData query through Exception - The type 'BadAmbiguousElementBinding:.' does not inherit from and is not a base type of 'BadAmbiguousElementBinding:.'. The type of 'KeySegments' must be related to the Type of the EntitySet.

    It's seem this error occurred  randomly. My web Api calls are made from an external application based on java, and this app works almost a year ago. I noticed this error after we migrated to V9, and sometimes when I retry the same call it works.

  • manojpatil5288 Profile Picture
    12 on at
    RE: API OData query through Exception - The type 'BadAmbiguousElementBinding:.' does not inherit from and is not a base type of 'BadAmbiguousElementBinding:.'. The type of 'KeySegments' must be related to the Type of the EntitySet.

    Hello SCV

    Thank you for response. 

    Yes, I have created query using  Rest Builder. It works properly on Development & UAT environment. It happens on Production, but this is not continues behavior,it work sometimes and fails sometimes (like if generate request for 10 times the it will fails at 2/3 time).   

    Regards,

     manoj

  • Suggested answer
    SCV Profile Picture
    1,004 on at
    RE: API OData query through Exception - The type 'BadAmbiguousElementBinding:.' does not inherit from and is not a base type of 'BadAmbiguousElementBinding:.'. The type of 'KeySegments' must be related to the Type of the EntitySet.

    Hi Manoj,

    Did you build this query using REST Builder? If so did it work there? If not I would suggest you to build and test the query using REST builder to make sure the query is alright.

  • Suggested answer
    manojpatil5288 Profile Picture
    12 on at
    RE: API OData query through Exception - The type 'BadAmbiguousElementBinding:.' does not inherit from and is not a base type of 'BadAmbiguousElementBinding:.'. The type of 'KeySegments' must be related to the Type of the EntitySet.

    Hello kfranck

    ,

    Still unable to find out the reason. Just has one guess that it is may be connectivity issue through API.

    I am used another way to fetch data using OrganizationData.svc and it works for me. Please check below sample organizationData.svc query. 

    http://[OrganizationBaseUrl]/[organizationaneme]/XRMServices/2011/OrganizationData.svc/entityNameSet?$select=[selectFieldListWithCommaSeperate]&$filter=[idfieldName] eq guid'[XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX]'

    Thanks

    manojpatil5288

  • Community Member Profile Picture
    on at
    RE: API OData query through Exception - The type 'BadAmbiguousElementBinding:.' does not inherit from and is not a base type of 'BadAmbiguousElementBinding:.'. The type of 'KeySegments' must be related to the Type of the EntitySet.

    hello,

    I also get this issue from CRM Web API. We recently migrate to V9.

    Any idea ?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans