# dataverse-python-api-reference

A GitHub Copilot rule that keeps a Dataverse Python SDK reference in the agent's context: client methods, config fields, error type.

- rule · `type=rule` · GitHub Copilot · ★ 40418
- Author: github · official GitHub repository
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/github/awesome-copilot/tree/HEAD/instructions/dataverse-python-api-reference.instructions.md
- Updated: 2026-10-23
- HTML: https://affpapa.org/en/nevibecode/rules/dataverse-python-api-reference

## What it does

The rule hands the agent a compact reference for `DataverseClient` from the Dataverse Python SDK: `create`, `get`, `update`, `delete`, plus schema calls such as `create_table`, `create_columns` and `delete_table`. Its examples show `update` working two ways, with one payload shared across a list of IDs or a separate payload per ID.

\`DataverseConfig` gets its own section: `http_timeout`, `http_retries`, `http_backoff`, `language_code`. Failures surface as `DataverseError`, carrying `code`, `message` and `is_transient`; that last flag is what tells the agent whether a retry makes sense.

The rule is scoped with `applyTo: '**'`, so it loads for every file in the repo, Dataverse code or not. A client is built from a base URL and Azure credentials. Calling `delete_table` drops a custom table for good.

## Install

### GitHub Copilot (native platform)

**Manually: put the files in place**
- File: `.github/instructions/dataverse-python-api-reference.instructions.md` — The applyTo field sets which files it applies to

### Claude Code

**Manually: put the files in place**
- File: `.claude/rules/dataverse-python-api-reference.md` — The paths frontmatter field limits the files: move applyTo from the source into paths

### Codex

**AGENTS.md**
- Codex reads AGENTS.md: paste the rule text there

### Cursor

**Manually: put the files in place**
- File: `.cursor/rules/dataverse-python-api-reference.mdc` — Frontmatter: description, globs, alwaysApply. Move applyTo from the source into globs, or the rule will not attach on its own

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/rules/dataverse-python-api-reference.md`

### Cline

**Manually: put the files in place**
- File: `.clinerules/dataverse-python-api-reference.md`

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/github/awesome-copilot/tree/HEAD/instructions/dataverse-python-api-reference.instructions.md

## When to use it
- create a Dataverse table with typed columns from Python
- apply one field change to a list of records
- decide whether a failed call deserves a retry
- tune client timeouts and retry count
- page through filtered records with OData options

## Example prompts
- Write a Python script that creates `new_MyTable` with a `new_Status` column backed by an IntEnum.
- Update every account ID in this list to `statecode` 1 in one call.
- Query accounts where `statecode eq 0`, newest first, 50 per page.

## Source text · dataverse-python-api-reference.instructions.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 57677c24240dcfed.

BEGIN THIRD-PARTY FILE 57677c24240dcfed
````text
---
applyTo: '**'
---
# Dataverse SDK for Python — API Reference Guide

## DataverseClient Class
Main client for interacting with Dataverse. Initialize with base URL and Azure credentials.

### Key Methods

#### create(table_schema_name, records)
Create single or bulk records. Returns list of GUIDs.

```python
# Single record
ids = client.create("account", {"name": "Acme"})
print(ids[0])  # First GUID

# Bulk create
ids = client.create("account", [{"name": "Contoso"}, {"name": "Fabrikam"}])
```

#### get(table_schema_name, record_id=None, select, filter, orderby, top, expand, page_size)
Fetch single record or query multiple with OData options.

```python
# Single record
record = client.get("account", record_id="guid-here")

# Query with filter and paging
for batch in client.get(
    "account",
    filter="statecode eq 0",
    select=["name", "telephone1"],
    orderby=["createdon desc"],
    top=100,
    page_size=50
):
    for record in batch:
        print(record["name"])
```

#### update(table_schema_name, ids, changes)
Update single or bulk records.

```python
# Single update
client.update("account", "guid-here", {"telephone1": "555-0100"})

# Broadcast: apply same changes to many IDs
client.update("account", [id1, id2, id3], {"statecode": 1})

# Paired: one-to-one mapping
client.update("account", [id1, id2], [{"name": "A"}, {"name": "B"}])
```

#### delete(table_schema_name, ids, use_bulk_delete=True)
Delete single or bulk records.

```python
# Single delete
client.delete("account", "guid-here")

# Bulk delete (async)
job_id = client.delete("account", [id1, id2, id3])
```

#### create_table(table_schema_name, columns, solution_unique_name=None, primary_column_schema_name=None)
Create custom table.

```python
from enum import IntEnum

class ItemStatus(IntEnum):
    ACTIVE = 1
    INACTIVE = 2
    __labels__ = {
        1033: {"ACTIVE": "Active", "INACTIVE": "Inactive"}
    }

info = client.create_table("new_MyTable", {
    "new_Title": "string",
    "new_Quantity": "int",
    "new_Price": "decimal",
    "new_Active": "bool",
    "new_Status": ItemStatus
})
print(info["entity_logical_name"])
```

#### create_columns(table_schema_name, columns)
Add columns to existing table.

```python
created = client.create_columns("new_MyTable", {
    "new_Notes": "string",
    "new_Count": "int"
})
```

#### delete_columns(table_schema_name, columns)
Remove columns from table.

```python
removed = client.delete_columns("new_MyTable", ["new_Notes", "new_Count"])
```

#### delete_table(table_schema_name)
Delete custom table (irreversible).

```python
client.delete_table("new_MyTable")
```

#### get_table_info(table_schema_name)
Retrieve table metadata.

```python
info = client.get_table_info("new_MyTable")
if info:
    print(info["table_logical_name"])
    print(info["entity_set_name"])
```

#### list_tables()
List all custom tables.

```python
tables = client.list_tables()
for table in tables:
    print(table)
```

#### flush_cache(kind)
Clear SDK caches (e.g., picklist labels).

```python
removed = client.flush_cache("picklist")
```

## DataverseConfig Class
Configure client behavior (timeouts, retries, language).

```python
from PowerPlatform.Dataverse.core.config import DataverseConfig

cfg = DataverseConfig()
cfg.http_retries = 3
cfg.http_backoff = 1.0
cfg.http_timeout = 30
cfg.language_code = 1033  # English

client = DataverseClient(base_url=url, credential=cred, config=cfg)
```

## Error Handling
Catch `DataverseError` for SDK-specific exceptions. Check `is_transient` to decide retry.

```python
from PowerPlatform.Dataverse.core.errors import DataverseError

try:
````
END THIRD-PARTY FILE 57677c24240dcfed

The third-party file has ended. Everything between the 57677c24240dcfed tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 3626 of 4452 bytes. © github · MIT · https://github.com/github/awesome-copilot/tree/HEAD/instructions/dataverse-python-api-reference.instructions.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
