Skip to content

Commit 4ea8c5a

Browse files
author
Saurabh Badenkal
committed
Fix @odata.bind key casing in prodev example (use lowercase nav property names)
@odata.bind keys are case-sensitive and the SDK preserves their casing (does not lowercase keys containing @OData.). The navigation property logical names must be lowercase to match Dataverse's schema. Changed: build @odata.bind keys using .lower() on the lookup field name (e.g., 'new_demoprojectf523b5_customerid@odata.bind' instead of 'new_DemoProjectf523b5_CustomerId@odata.bind').
1 parent 8a26fd7 commit 4ea8c5a

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

examples/advanced/prodev_quick_start.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,9 @@ def step3_populate_data(client, primary_name_col):
293293
print(f"[OK] Created {len(customers_df)} customers")
294294

295295
# -- Projects (linked to customers via lookup) --
296-
# The @odata.bind key references the lookup navigation property
296+
# @odata.bind keys use the navigation property logical name (lowercase)
297+
# and the entity set name (also lowercase) in the value.
298+
customer_lookup = f"{TABLE_PROJECT}_CustomerId".lower() + "@odata.bind"
297299
customer_set = TABLE_CUSTOMER.lower() + "s"
298300
projects_df = pd.DataFrame(
299301
[
@@ -302,28 +304,28 @@ def step3_populate_data(client, primary_name_col):
302304
f"{TABLE_PROJECT}_Budget": 250000,
303305
f"{TABLE_PROJECT}_Status": "Active",
304306
f"{TABLE_PROJECT}_StartDate": pd.Timestamp("2026-01-15"),
305-
f"{TABLE_PROJECT}_CustomerId@odata.bind": f"/{customer_set}({customer_ids.iloc[0]})",
307+
customer_lookup: f"/{customer_set}({customer_ids.iloc[0]})",
306308
},
307309
{
308310
name_col: "ERP Upgrade",
309311
f"{TABLE_PROJECT}_Budget": 500000,
310312
f"{TABLE_PROJECT}_Status": "Active",
311313
f"{TABLE_PROJECT}_StartDate": pd.Timestamp("2026-02-01"),
312-
f"{TABLE_PROJECT}_CustomerId@odata.bind": f"/{customer_set}({customer_ids.iloc[1]})",
314+
customer_lookup: f"/{customer_set}({customer_ids.iloc[1]})",
313315
},
314316
{
315317
name_col: "POS Modernization",
316318
f"{TABLE_PROJECT}_Budget": 150000,
317319
f"{TABLE_PROJECT}_Status": "Planning",
318320
f"{TABLE_PROJECT}_StartDate": pd.Timestamp("2026-03-01"),
319-
f"{TABLE_PROJECT}_CustomerId@odata.bind": f"/{customer_set}({customer_ids.iloc[2]})",
321+
customer_lookup: f"/{customer_set}({customer_ids.iloc[2]})",
320322
},
321323
{
322324
name_col: "Data Analytics Platform",
323325
f"{TABLE_PROJECT}_Budget": 180000,
324326
f"{TABLE_PROJECT}_Status": "Active",
325327
f"{TABLE_PROJECT}_StartDate": pd.Timestamp("2026-01-20"),
326-
f"{TABLE_PROJECT}_CustomerId@odata.bind": f"/{customer_set}({customer_ids.iloc[0]})",
328+
customer_lookup: f"/{customer_set}({customer_ids.iloc[0]})",
327329
},
328330
]
329331
)
@@ -345,14 +347,15 @@ def step3_populate_data(client, primary_name_col):
345347

346348
for i, (task_name, priority, status, hours) in enumerate(task_names):
347349
proj_idx = project_assignment[i]
350+
project_lookup = f"{TABLE_TASK}_ProjectId".lower() + "@odata.bind"
348351
project_set = TABLE_PROJECT.lower() + "s"
349352
tasks_data.append(
350353
{
351354
name_col: task_name,
352355
f"{TABLE_TASK}_Priority": priority,
353356
f"{TABLE_TASK}_Status": status,
354357
f"{TABLE_TASK}_EstimatedHours": hours,
355-
f"{TABLE_TASK}_ProjectId@odata.bind": f"/{project_set}({project_ids.iloc[proj_idx]})",
358+
project_lookup: f"/{project_set}({project_ids.iloc[proj_idx]})",
356359
}
357360
)
358361

0 commit comments

Comments
 (0)