dataverse-web-api
Dataverse Web API — Metadata & Schema
CRITICAL RULES
-
Always pass
MSCRM.SolutionUniqueNameheader when creating any component. Without it, components land in the Default Solution with the environment's random default publisher prefix (e.g.,cr8a3_mytable). The schema name is permanently baked with that random prefix. The component cannot be packaged into a deployable solution without being manually re-added — and it cannot be renamed. -
Column (Attribute) creation MUST include correct
@odata.type. Omitting or using the wrong type causes a 400 error with no helpful message. Example:"@odata.type": "Microsoft.Dynamics.CRM.StringAttributeMetadata". Seeresources/columns-attributes.mdfor all valid types. -
Every
POST /EntityDefinitionsMUST include aStringAttributeMetadatawithIsPrimaryName: true. TheAttributesarray inline in the table creation body must contain exactly one primary name attribute. Omitting it causes a 400. -
Metadata
PUTrequires the FULL definition — partial updates silently zero unspecified properties. The API returns 204 (success) when you send a partial payload, but every property you omit is cleared to its default. AlwaysGETthe current definition first, modify the specific properties, thenPUTthe complete object. AddMSCRM.MergeLabels: trueheader onPUTto preserve labels in other languages. -
Add
Consistency: Strongheader when reading metadata immediately after writing. Without it,GET EntityDefinitionsmay return a stale cached response, causing you to wrongly conclude a write failed or overwrite just-written values. -
FormXmlandLayoutXmlmust stay in sync withFetchXml. Every column in a view'slayoutxmlMUST appear in itsfetchxml. Mismatches cause silent runtime errors at view render time — the API accepts the write, the error only appears to users when loading the view. -
Publishing is required after updating existing definitions — not after creating new ones. New tables and columns auto-publish. Updating existing forms, views, sitemaps, or ribbons requires explicit
PublishXml. Use scoped publish:<entities><entity>logicalname</entity></entities>.PublishAllXmlcauses visible latency spikes for all users — avoid in production. -
Windows: Always use PowerShell
.ps1for OData API calls. Bash interprets$filter,$select,$expand,$orderbyas shell variables and silently strips them. Write.ps1files, run withpowershell -ExecutionPolicy Bypass -File.