Skip to content

Use CreateEntities API for table creation#183

Draft
vrathee-msft wants to merge 7 commits into
mainfrom
users/vikasrathee/create-entities-api
Draft

Use CreateEntities API for table creation#183
vrathee-msft wants to merge 7 commits into
mainfrom
users/vikasrathee/create-entities-api

Conversation

@vrathee-msft
Copy link
Copy Markdown

Summary

This PR updates Dataverse table creation to use the CreateEntities API instead of posting to EntityDefinitions. It also updates the metadata payload types for supported attribute kinds to their corresponding Complex*Metadata variants so the request shape matches the new bulk/create-entities contract.

Test Executed

  • Unit Tests are run against the change All 1389 Pass
  • Run basic functional test as a validation.
  • Black formatter pass.

@vrathee-msft vrathee-msft requested a review from a team as a code owner May 15, 2026 01:29
Copilot AI review requested due to automatic review settings May 15, 2026 01:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates table creation metadata requests to target the Dataverse CreateEntities API and adjusts supported attribute payload @odata.type values to their Complex*Metadata variants.

Changes:

  • Switches _create_entity from posting to EntityDefinitions to posting to CreateEntities.
  • Wraps entity metadata in an Entities list for the new request shape.
  • Updates unit expectations for complex attribute metadata and nested table payload access.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
src/PowerPlatform/Dataverse/data/_odata.py Updates table creation endpoint/payload and changes attribute metadata type names to Complex variants.
tests/unit/data/test_odata_internal.py Updates unit test assertions for Complex metadata types and nested Entities[0] payload structure.
Comments suppressed due to low confidence (7)

tests/unit/data/test_odata_internal.py:1529

  • The test docstring still says this produces DecimalAttributeMetadata, but the expected @odata.type is now ComplexDecimalAttributeMetadata. Please update the wording to avoid documenting the old payload type.
        """'decimal' produces DecimalAttributeMetadata."""
        result = self.od._attribute_payload("new_Price", "decimal")
        self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.ComplexDecimalAttributeMetadata")

tests/unit/data/test_odata_internal.py:1539

  • The test docstring still says this produces DoubleAttributeMetadata, but the expected @odata.type is now ComplexDoubleAttributeMetadata. Please update the wording to match the new payload type.
        """'float' produces DoubleAttributeMetadata."""
        result = self.od._attribute_payload("new_Score", "float")
        self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.ComplexDoubleAttributeMetadata")

tests/unit/data/test_odata_internal.py:1549

  • The test docstring still says this produces DateTimeAttributeMetadata, but the expected @odata.type is now ComplexDateTimeAttributeMetadata. Please update the wording to match the new payload type.
        """'datetime' produces DateTimeAttributeMetadata."""
        result = self.od._attribute_payload("new_CreatedDate", "datetime")
        self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.ComplexDateTimeAttributeMetadata")

tests/unit/data/test_odata_internal.py:1559

  • The test docstring still says this produces BooleanAttributeMetadata, but the expected @odata.type is now ComplexBooleanAttributeMetadata. Please update the wording to match the new payload type.
        """'bool' produces BooleanAttributeMetadata."""
        result = self.od._attribute_payload("new_IsActive", "bool")
        self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.ComplexBooleanAttributeMetadata")

tests/unit/data/test_odata_internal.py:1569

  • The test docstring still says this produces FileAttributeMetadata, but the expected @odata.type is now ComplexFileAttributeMetadata. Please update the wording to match the new payload type.
        """'file' produces FileAttributeMetadata."""
        result = self.od._attribute_payload("new_Attachment", "file")
        self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.ComplexFileAttributeMetadata")

tests/unit/data/test_odata_internal.py:1579

  • The test docstring still says this produces MemoAttributeMetadata, but the expected @odata.type is now ComplexMemoAttributeMetadata. Please update the wording to match the new payload type.
        """'memo' produces MemoAttributeMetadata with MaxLength 4000."""
        result = self.od._attribute_payload("new_Notes", "memo")
        self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.ComplexMemoAttributeMetadata")

tests/unit/data/test_odata_internal.py:1594

  • The test docstring still says this produces StringAttributeMetadata, but the expected @odata.type is now ComplexStringAttributeMetadata. Please update the wording to match the new payload type.
        """'string' produces StringAttributeMetadata with MaxLength 200."""
        result = self.od._attribute_payload("new_Title", "string")
        self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.ComplexStringAttributeMetadata")

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if dtype_l in ("string", "text"):
return {
"@odata.type": "Microsoft.Dynamics.CRM.StringAttributeMetadata",
"@odata.type": "Microsoft.Dynamics.CRM.ComplexStringAttributeMetadata",
"HasActivities": False,
"HasNotes": True,
"IsActivity": False,
"Attributes": attributes,
solution_unique_name: Optional[str] = None,
) -> Dict[str, Any]:
url = f"{self.api}/EntityDefinitions"
url = f"{self.api}/CreateEntities"
self.od._create_table("new_TestTable", {}, primary_column_schema_name="new_CustomName")
post_json = self.od._request.call_args.kwargs["json"]
attrs = post_json["Attributes"]
attrs = post_json["Entities"][0]["Attributes"]
Comment on lines 1517 to +1519
"""'int' produces IntegerAttributeMetadata."""
result = self.od._attribute_payload("new_Count", "int")
self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.IntegerAttributeMetadata")
self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.ComplexIntegerAttributeMetadata")
@vrathee-msft
Copy link
Copy Markdown
Author

@vrathee-msft please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree company="Microsoft"

@vrathee-msft vrathee-msft marked this pull request as draft May 15, 2026 18:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment on lines 1598 to 1600
# Enum-based local option set support
if isinstance(dtype, type) and issubclass(dtype, Enum):
return self._enum_optionset_payload(column_schema_name, dtype, is_primary_name=is_primary_name)
solution_unique_name: Optional[str] = None,
) -> Dict[str, Any]:
url = f"{self.api}/EntityDefinitions"
url = f"{self.api}/CreateEntities"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants