CRM Web API sample code published

I’m happy to announce that we’ve just published the first set of samples for the Microsoft Dynamics CRM Web API.

The CRM Web API was released nine months ago and all of our samples so far have simply demonstrated raw HTTP requests and responses. These are the first set of samples you can download and run using the Web API. You can find information about these samples at Web API Samples.

The samples are posted on the MSDN Code Gallery. These samples are for C# and client-side JavaScript. Here is a list of this set of samples: C# and Client-side JavaScript Web API samples.

Scope of these samples

Being a RESTful OData v4 service, the CRM Web API allows developers many options about how to interact with the service—there is no single ‘correct way’ to do it. These samples are not intended to demonstrate any type of single preferred way to use the Web API. Instead, they simply provide examples that show straightforward use of the CRM Web API.

Many people have been asking for re-usable helper libraries so that they can simply put the Web API to use without having to be concerned about their inner workings. This is not the purpose of these samples.

Except for a set of C# helper libraries to manage authentication, these samples do not represent helper libraries to perform CRM data operations. These samples have been written to expose the specific low-level configurations that make the specific OData v4 capabilities we have implemented work. We have tried to keep them as light as possible, which means that we have not tried to encapsulate operations behind methods and provide a de facto helper library. Our goal is to demonstrate how these operations are performed so that developers can create their own helper libraries which align with how they wish to use the Web API.

There are a number of helper libraries for OData which you can find at http://www.odata.org/libraries/.

If you are looking for CRM specific helper libraries or code generators, please refer to these community resources:

The approach we chose

Because there are so many different approaches developers might take, we have tried to be very clear about the approach we have chosen for these samples. Each sample includes a specific set of operations which are described in a language neutral way that includes the HTTP requests and responses as well as the output of the sample.

For example, the Web API Basic Operations Sample provides the common set of operations which is implemented by both the Web API Basic Operations Sample (C#) and the Web API Basic Operations Sample (Client-side JavaScript). In the future we can provide additional samples with different languages and show how that language or technology can be used to achieve the same result.

For each language sample, we have provided details about the particular approach we chose.

  • Web API Samples (C#) describes that we chose to use the Json.NET library together with the standard .NET framework HTTP messaging classes. The C# samples do include helper libraries that manage the configuration data about the service, information about applications registration, and authentication using ADAL or Windows Authentication.
  • Web API Samples (Client-side JavaScript) topic describes how we chose to provide a basic request helper function and use a specific ES6 Promise polyfill so that the samples demonstrate the use of Promises.

What’s next?

This is just our first set of Web API samples. We intend to expand the samples available to include use of the ODataLib Client for .Net and samples using Java. We also intend to expand the breadth of operations we cover to include batch operations.

Please let us know what you think.

Jim Daly

Related
Recommended