Skip to main content

Samples

The MyCRM API samples repository is home to the C# sample client, the OpenAPI Specification and the Postman collections. Open the repository to find these developer resources, or explore the sample client below.

See a working MyCRM integration from inside a C# application. The sample client lets you choose an example, run it against the API and inspect the result, then follow the code to understand how it works.

What is the sample client?​

The MyCrmSampleClient is an interactive .NET console application. It provides a menu of examples so developers can see how authentication, API requests and JSON:API responses fit together in C#.

Its HTTP client is generated from OpenAPI using Microsoft Kiota. Helper methods make query construction more readable, and shared sample state lets related examples reuse selected records. It is a learning application and reference implementation, rather than a hosted integration service or a promise of a separately supported SDK.

The examples cover:

AreaWhat it demonstrates
AuthenticationObtain an OAuth token and attach authentication and adviser headers
AdvisersList advisers and retrieve profile details
ContactsRead, filter, sort and include related addresses
Contact groupsFollow related contacts and select fields
DealsRead recent deals and related information
Marketing consentUpdate a contact's consent through PATCH
LeadsCreate a new lead
Deal notesCreate a note, then update it

Run your first example​

You will need the .NET SDK and the credentials and URLs issued for your application. Clone or download the samples repository, then configure MyCrmSampleClient/appsettings.json locally:

SettingWhat to supply
Auth.UrlComplete authentication URL
Auth.ClientID and Auth.ClientSecretIssued application credentials
Auth.ScopesSpace-separated approved scopes
MyCRM.UrlAPI base URL
MyCRM.AdviserContactIdAdviser contact identifier

Keep populated configuration private and out of source control. From the repository directory, run:

cd MyCrmSampleClient
dotnet run

Use the arrow keys to choose an example and press Enter. Start with a read example your credentials permit, such as latest-contacts. The results appear in the console. Some examples save record identifiers in a local state file for later examples to reuse; you can view or clear that state from the menu.

Creation and update examples make real changes. Use an agreed test environment and appropriate test records, and check the selected record before running a write example. Your application’s access may not permit every example in the menu.

See the sample client README in the repository for prerequisites, configuration, running instructions and the current list of samples.

For production, apply your own secure configuration, token caching, retry policy, monitoring and validation. Treat generated schemas as the contract for their recorded API version; keep your generated client aligned with the version you use.

Useful recipes on this site​