Technicality
- Low Does not need any software engineering knowledge.
- Intermediate Assumes you know software engineering principles, but knowledge about a specific technology is not required.
- Specific The topic is in-depth about a specific technology.
Populating Lookup Values Correctly in Dataverse via API
If you've worked at all within the Power Platform or Dataverse, you know exactly why this is important. This is a short and sweet mini tutorial on how to get those lookup columns populated when using the Dataverse API both when the GUID of the lookup is known, and not known.
If you've worked at all within the Power Platform or Dataverse, you know that having lookup columns be correctly populated is crucial both for the business and developer sanity. If you’re in Power Automate, it’s no biggy. But oftentimes in larger environments, you need to add these values via the Dataverse API. Admittedly, it can be a little tricky and unintuitive if you are not used to this.
Quick, in a Nutshell
In the body of your POST request on the property of the lookup column, use the @odata.bind method. @odata.bind accepts either
the primary key, or any alternate key.
Include the headers OData-Version: x.x and OData-MaxVersion: x.x (I use 4.0) on every request,
not just batch ones.
When sending to a batch operation endpoint, such as Microsoft.Dynamics.CRM.CreateMultiple, wrap everything in @json(' … ') (note the quotes).
@json('{
"Targets": [
{
"@odata.type": "Microsoft.Dynamics.CRM.crd31_city",
"crd31_newcolumn": "Fort Worth",
"[email protected]": "/crd31_countries(3f2504e0-4f89-11d3-9a0c-0305e82c3301)"
},
{
"@odata.type": "Microsoft.Dynamics.CRM.crd31_city",
"crd31_newcolumn": "Vancouver",
"[email protected]": "/crd31_countries(1feaed24-93dc-f111-84ea-70a8a59bffa7)"
}
]
}') Important: Note the single'and double"quote usage.
For more information on what the full request looks like, including the headers, see the relevant section below.
Note: In this tutorial, we are not covering a specific product from which you send
HTTP requests. Depending on where you're sending it from (like a VM, Azure Data Factory, etc.), you
will need to authenticate to Dataverse (Authorization header) and possibly
set a Resource (the audience your sender requests a token for, usually your environment URL).
Details on how to do that depend on what you’re using. Feel free to email me with any questions and I’ll see if I can help. API Requests When You Know the GUID
To add a lookup, Dataverse provides a method called .bind. When you
provide this method and pass it a GUID, Dataverse will add it as a Lookup value as if you did it
through Power Automate or on the table itself.
If you already have the GUID (the GUID on the Dataverse table, not just any primary key from your
data source), you can simply pass that in to the .bind() method within the
property in the request body.
Here is that HTTP request.
Note: It is v9.2 as of writing this guide.
- URL
https://[ ORG NAME ].crm.dynamics.com/api/data/v9.2/[ TABLE ENTITY SET NAME ]- Method
POST- Body
{ "[ LOOKUP NAVIGATION PROPERTY ]@odata.bind": "/[ LOOKUP TABLE ENTITY SET NAME ]([ LOOKUP ROW GUID ])" // your other data }- Resource (if applicable, dependent on the sender)
https://[ ORG NAME ].crm.dynamics.com- Auth
- Out of scope of guide. Use whatever you do to connect to Dataverse.
- Headers
Content-Type: application/json Accept: application/json OData-Version: 4.0 OData-MaxVersion: 4.0 Prefer: return=representation,odata.include-annotations="*"
Click here to show an example HTTP request.
- URL
https://org1234567f.crm.dynamics.com/api/data/v9.2/crd31_cities- Auth
- System-managed identity.
- Resource (if applicable)
https://org1234567f.crm.dynamics.com- Body
{ "crd31_newcolumn": "Fort Worth", "[email protected]": "/crd31_countries(3f2504e0-4f89-11d3-9a0c-0305e82c3301)" }
When You Don't Know the GUID, an Alternative Method
Consider this scenario: You have Azure Data Factory pipelines or Azure Function apps that take external data from wherever and you need to process it into Dataverse tables. In the previous section, we knew the GUID, therefore it was pretty straightforward and easy. But let's say you do not want to pull data from Dataverse first to get the GUIDs because of either security reasons or the compute cost. You can still populate lookup columns properly in Dataverse through the use of alternate keys.
In a nutshell, there has to be something on the table that is known. After all (and this is just a normal database thing unrelated to the Power Platform), you can't create relationships off of completely unknown things.
Think about what fields are in common between your data and the Dataverse tables.
For example, if you have a countries table, you could have an alternate
key be the country codes, like “US”, “CA”, “MX”. In this scenario, country codes are a perfect
example because it's a common name that can easily be included in external data sources. Your
business case may not be as simple as that, and finding out what that would be and how reliable it
would be is half the fun.
The only difference between the primary key and alternate key is that the alternate key needs to be specified.
With the primary key (previous section), we simply just passed the GUID. For alt keys, pass the name of the column with the value of the row to be used.
"[ LOOKUP NAVIGATION PROPERTY ]@odata.bind": "/[ LOOKUP TABLE ENTITY SET NAME ]([ KEY COLUMN LOGICAL NAME ]='[ VALUE ]')" Note: Note the use of single'and double"quotes.
The full syntax is:
{
"[ LOOKUP NAVIGATION PROPERTY ]@odata.bind": "/[ LOOKUP TABLE ENTITY SET NAME ]([ KEY COLUMN LOGICAL NAME ]='[ VALUE ]')"
// your other data
} Click here to show an example HTTP request.
- URL
https://org1234567f.crm.dynamics.com/api/data/v9.2/crd31_cities- Auth
- System-managed identity.
- Resource (if applicable)
https://org1234567f.crm.dynamics.com- Body
{ "crd31_newcolumn": "Dallas", "[email protected]": "/crd31_countries(crd31_isocode='US')" // Other data attached as normal }
How to Create an Alternate Key
First, let’s create the alt key. On the tables screen, go to Keys.

- Make sure your column that you want to be the key is created and is “Business Required.” Then, go to New Key.
Select the column to be the key, name it, then save.
Steps 2 and 3. Note: For your future self, name it “Key”, e.g. “Country Code Key”, “Part Number Key”, etc.
This starts a job that adds the new alt key to the selected column on your table. An alt key requires the column to be indexed in the database, so this action may take a while depending on your table size and tenant. This job must be completed before the Dataverse API will let you use it.
Note: For me, the alt key takes 10 minutes before it’s ready. It may be longer or shorter for you.
Important: Wait for it to be “Active” before continuing.

- That’s it!
The Dataverse API is now ready to receive POST requests.
Requests Using an Alternate Key
Dataverse can add these lookups based on the exact same methods and endpoints as if we knew the GUID.
Here’s what those requests look like.
Add a Single Row with a Lookup Column
- URL
https://[ ORG NAME ].crm.dynamics.com/api/data/v9.2/[ TABLE ENTITY SET NAME ]- Method
POST- Body
{ "crd31_newcolumn": "Dallas", "[email protected]": "/crd31_countries(crd31_isocode='US')" // Other data attached as normal }
For example, the URL may look like this:
https://org1234567a.crm.dynamics.com/api/data/v9.2/abc123_cities Batch Operations / Adding Multiple
The previous examples only added one row. Here, we're adding multiple rows. The body of the request
must be wrapped in OData’s @json().
Here is that HTTP request.
- URL
https://[ ORG NAME ].crm.dynamics.com/api/data/v9.2/[ TABLE ENTITY SET NAME ]/Microsoft.Dynamics.CRM.CreateMultiple- Method
POST- Body
@json('{ "Targets": [ { "@odata.type": "Microsoft.Dynamics.CRM.[ TABLE LOGICAL NAME ]", "[ LOOKUP NAVIGATION PROPERTY ]@odata.bind": "/[ LOOKUP TABLE ENTITY SET NAME ]([ LOOKUP ROW GUID ])" // your other data }, { "@odata.type": "Microsoft.Dynamics.CRM.[ TABLE LOGICAL NAME ]", "[ LOOKUP NAVIGATION PROPERTY ]@odata.bind": "/[ LOOKUP TABLE ENTITY SET NAME ]([ LOOKUP ROW GUID ])" // your other data } ] }')- Resource (if applicable, dependent on the sender)
https://[ ORG NAME ].crm.dynamics.com- Auth
- Out of scope of guide. Use whatever you do to connect to Dataverse.
- Headers
Content-Type: application/json Accept: application/json OData-Version: 4.0 OData-MaxVersion: 4.0 Prefer: return=representation,odata.include-annotations="*"
Important: Wrap the entire body in@json(' … '), with single'quotes on the outside and double"quotes on the inside.
Note: Every row inTargetsneeds its own@odata.type, and all of them have to be rows for the same table.
Click here to show an example HTTP request.
- URL
https://org1234567f.crm.dynamics.com/api/data/v9.2/crd31_cities/Microsoft.Dynamics.CRM.CreateMultiple- Auth
- System-managed identity.
- Resource (if applicable)
https://org1234567f.crm.dynamics.com- Body
@json('{ "Targets": [ { "@odata.type": "Microsoft.Dynamics.CRM.crd31_city", "crd31_newcolumn": "Houston", "[email protected]": "/crd31_countries(3f2504e0-4f89-11d3-9a0c-0305e82c3301)" }, { "@odata.type": "Microsoft.Dynamics.CRM.crd31_city", "crd31_newcolumn": "Vancouver", "[email protected]": "/crd31_countries(1feaed24-93dc-f111-84ea-70a8a59bffa7)" } ] }')
Finding Your Variables
In the Power Platform, finding what to call things can be half the battle. Here is where you can find all the needed names in this article.
Most of these live on the table's page in Power Apps: go to make.powerapps.com → Tables (set the filter to All if you don't see yours), open your table, and look for the Tools menu in the Table properties area. Its copy commands put
the exact name on your clipboard, so there's nothing to retype.
[ ORG NAME ]
The first part of your environment's URL, used in every request URL and in the Resource. In Power
Apps, select the Settings gear in the top-right corner, then Developer resources. Your org name is the part of the Web API endpoint before .api.crm.dynamics.com.
You can also find it in the Power Platform admin center: Environments → your environment → Environment URL.
Note: This is the org name, not the Organization ID GUID shown on the same pages. And if your endpoint isn't plaincrm, likecrm9for GCC orcrm4for Europe, use that in every URL in this article too.
Example: org1234567f
[ TABLE ENTITY SET NAME ]
The name of the table you're adding rows to, as the Web API knows it. It's usually the plural of the logical name, but don't count on that. Open the table, click the three vertical dots (⋮) in the Table properties area, then Tools → Copy set name.
To see every entity set name in your environment at once, open this in your browser while signed in, and use Ctrl+F to find yours:
https://[ ORG NAME ].crm.dynamics.com/api/data/v9.2/ Example: crd31_cities
[ TABLE LOGICAL NAME ]
Only used in @odata.type for batch requests. Open the table, click the
three vertical dots (⋮) in the Table properties area, then Tools → Copy logical name.
Example: crd31_city
[ LOOKUP NAVIGATION PROPERTY ]
The name that goes in front of @odata.bind. This one is case-sensitive, and
Power Apps doesn't show it under this name anywhere.
For lookup columns you created yourself, it's usually the lookup column's schema name, which keeps its capital letters (the logical name is all lowercase). Go to the table's Columns, select the lookup column, and expand Advanced options to see its Schema name.
To be sure, paste this into your browser while signed in to the environment, and look for the row
whose ReferencingAttribute is your lookup column. Its ReferencingEntityNavigationPropertyName is the value you want.
https://[ ORG NAME ].crm.dynamics.com/api/data/v9.2/EntityDefinitions(LogicalName='[ TABLE LOGICAL NAME ]')/ManyToOneRelationships?$select=ReferencingAttribute,ReferencingEntityNavigationPropertyName Example: crd31_Country
[ LOOKUP TABLE ENTITY SET NAME ]
The entity set name of the table the lookup points to. Same steps as [ TABLE ENTITY SET NAME ], but on the lookup table.
Example: crd31_countries
[ LOOKUP ROW GUID ]
The ID of the row you're pointing the lookup at. Open the lookup table and, in its columns and data view, show the column with the same name as the table (for the Country table, it's Country). That column holds each row's GUID.
If you're in a model-driven app, you can also open the row and copy the id= value from the address bar.
Example: 3f2504e0-4f89-11d3-9a0c-0305e82c3301
[ KEY COLUMN LOGICAL NAME ]
The logical name of the column your alternate key is built on, on the lookup table. Go to the lookup
table's Columns, select the column, and expand Advanced options to
see its Logical name. Use the same steps for any other column you send in the body,
like crd31_newcolumn in the examples.
Example: crd31_isocode
[ VALUE ]
The alternate key value of the row you want, straight from your own data. Text values go in single quotes.
Example: 'US'