Dynamics 365 Quick Tips · Functional Info

{Common Data Service} Install and Uninstall Sample Data programatically

Sample data is great for any demo and testing of a feature in CRM instance. We can install and uninstall Sample Data from CRM by navigating to Settings->Data Management->Sample Data

We could also install and uninstall Sample Data using Web API and Organization Service through C# code.

Using the Web API

Install sample data using the InstallSampleData Action

POST [Organization URI]/api/data/v9.0/InstallSampleData HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0

Uninstall sample data using the UninstallSampleData Action

POST [Organization URI]/api/data/v9.0/UninstallSampleData HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0

Using the Organization Service

Install sample data using the InstallSampleDataRequest

var request = new InstallSampleDataRequest();
_orgService.Execute(request);

Uninstall sample data using the UninstallSampleDataRequest

var request = new UninstallSampleDataRequest();
_orgService.Execute(request);

Hope this helps!

One thought on “{Common Data Service} Install and Uninstall Sample Data programatically

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s