Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

difference between odata.id and odata.bind. Please explain me which is better and in what situation is used. WEBAPI

Posted on by Microsoft Employee

WEBAPI

difference between odata.id and odata.bind. Please explain me which is  better and in what situation is used.

*This post is locked for comments

  • Andreas Cieslik Profile Picture
    Andreas Cieslik 9,265 on at
    RE: difference between odata.id and odata.bind. Please explain me which is better and in what situation is used. WEBAPI

    I think you need an extra put request to set the lookup, but you cannot use this format to export data:

    msdn.microsoft.com/.../mt607875.aspx

  • Peter Bohn Profile Picture
    Peter Bohn on at
    RE: difference between odata.id and odata.bind. Please explain me which is better and in what situation is used. WEBAPI

    Hi,

    i have a question too.

    We export dynamics365 crm data like that:

    https://xxxxxxxxx.crm4.dynamics.com/api/data/v9.0/accounts?$select=accountid,accountnumber,_parentaccountid_value

    but the import with js-webapi9 needs the lookups not in this format:

    {
      "@odata.context": "assoffice.crm4.dynamics.com/.../v9.0$metadata#accounts(accountid,accountnumber,_parentaccountid_value)",
      "value": [
        {
          "@odata.etag": "W/\"3179350\"",
          "accountid": "c42e134c-49ab-e711-a823-000d3a27889d",
          "accountnumber": "5555444444444",
          "_parentaccountid_value": "c42e134d-49cb-f711-b823-012d3a25889d"
        },

    no, it needs Lookups in this format:

    {
      "@odata.context": "assoffice.crm4.dynamics.com/.../v9.0$metadata#accounts(accountid,accountnumber,_parentaccountid_value)",
      "value": [
        {
          "@odata.etag": "W/\"3179350\"",
          "accountid": "c42e134c-49ab-e711-a823-000d3a27889d",
          "accountnumber": "5555444444444",
          "parentaccountid@odata.bind": "/accounts(ab822393-731c-e811-a84d-000d3a274ce0)"
        },

    So - we need to export the data in the @odata.bind-Format. Then everything is fine.

    Is this possible?

    many thx.

    PeB

  • Suggested answer
    Andreas Cieslik Profile Picture
    Andreas Cieslik 9,265 on at
    RE: difference between odata.id and odata.bind. Please explain me which is better and in what situation is used. WEBAPI

    Basically there is no general rule. The data model is the basis of an OData service. OData service uses an abstract data model called Entity Data Model (EDM) to describe the exposed data in the service. OData client can issue a GET request to the root URL of the OData service with $metadata to get an XML representation of the service’s data model.

    The schema of the MS CRM Web Api is explained a bit here:

    msdn.microsoft.com/.../mt607990.aspx

    and can be downloaded here:

    [Organization URI]/api/data/v8.2/$metadata

    So Microsoft defined the schema of their model to request and retrieve data leaned on to the ODATA protocol that can be read on here:

    docs.oasis-open.org/.../odata-v4.0-os-part1-protocol.pdf

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: difference between odata.id and odata.bind. Please explain me which is better and in what situation is used. WEBAPI

    odata.id is also used in associating records.So why is that used when odata.bind is available

  • Suggested answer
    Andreas Cieslik Profile Picture
    Andreas Cieslik 9,265 on at
    RE: difference between odata.id and odata.bind. Please explain me which is better and in what situation is used. WEBAPI

    With odata.bind you bind the URI (for a data record) to e.g. a lookup field in a web api request as explained here:

    msdn.microsoft.com/.../mt770368.aspx

    odata.id you usually retrieved from a response stream, for e.g. lookup field or a collection of records.

    if you parse out the odata.id values you can use them in return to do further actions, e.g. sample above.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans