Interact with Dataverse Web API for CRUD and batch operations
✓Works with OpenClaudeYou are a Dynamics 365 developer. The user wants to interact with Dataverse Web API to perform CRUD operations and batch requests.
What to check first
- Verify your Dynamics 365 environment URL (e.g.,
https://yourorg.crm.dynamics.com) - Confirm you have an Azure AD app registration with
user_impersonationpermission for Dataverse - Check your client ID, tenant ID, and client secret are available for authentication
- Run a test REST call to
https://yourorg.api.dynamics.com/api/data/v9.2/to verify API connectivity
Steps
- Authenticate to Azure AD using your app registration credentials to get an access token via the OAuth 2.0 client credentials flow
- Set the authorization header with the bearer token and
Content-Type: application/jsonfor all requests - For create operations, POST to
https://yourorg.api.dynamics.com/api/data/v9.2/{table_name}with the entity object in the request body - For read operations, GET from the same endpoint with query parameters like
$select,$filter,$orderby, and$topto retrieve specific records - For update operations, PATCH to
https://yourorg.api.dynamics.com/api/data/v9.2/{table_name}({id})with only the fields you want to change - For delete operations, send a DELETE request to the full entity URI with the record ID
- For batch operations, POST to
https://yourorg.api.dynamics.com/api/data/v9.2/$batchwith multipart content containing multiple requests in a single payload - Parse the response status codes (201 for create, 200 for read/update, 204 for delete, 200 for batch) and handle errors with detailed error messages from
error.innererror.message
Code
const https = require('https');
class DataverseClient {
constructor(orgUrl, clientId, clientSecret, tenantId) {
this.orgUrl = orgUrl;
this.clientId = clientId;
this.clientSecret = clientSecret;
this.tenantId = tenantId;
this.accessToken = null;
this.tokenExpiry = null;
}
async getAccessToken() {
if (this.accessToken && new Date() < this.tokenExpiry) {
return this.accessToken;
}
const tokenUrl = `https://login.microsoftonline.com/${this.tenantId}/oauth2/v2.0/token`;
const body = new URLSearchParams({
client_id: this.clientId,
client_secret: this.clientSecret,
scope: `${this.orgUrl}/.default`,
grant_type: 'client_credentials'
});
return new Promise((resolve, reject) => {
const request = https.request(tokenUrl,
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Dynamics 365 Skills
Other Claude Code skills in the same category — free to download.
Dynamics 365 Plugin
Build C# plugins with pre/post operation steps and execution pipeline
D365 Power Automate
Create Power Automate flows for Dynamics 365 automation
D365 Model-Driven App
Build model-driven apps with forms, views, and business rules
D365 Web Resources
Create JavaScript web resources for form customization
D365 FetchXML
Write FetchXML queries for advanced data retrieval and reporting
D365 Business Central
Develop AL extensions for Dynamics 365 Business Central
D365 Finance & Operations
Develop X++ customizations for Dynamics 365 Finance & Operations
D365 PCF Control
Build Power Apps Component Framework custom controls
Want a Dynamics 365 skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.