POWEROBJECTS

718 Washington Ave. N. Suite #101
Minneapolis, MN 55401
View map and all Locations

Send us a message

In order to position CRM as a platform for application development, its web services need to be easily accessed by a wide array of consumers while still exposing the majority of the functionality the system provides. The new Web API solves both of these problems, and in today’s blog, we’ll show you how to get started with the CRM 2016 Web API.

crm-2016

Prior to CRM 2016, developers were able to access the SOAP based endpoint and have full access to all the APIs CRM made available, but the cost was getting authenticated and working with it from non-.NET applications was challenging. The other alternative was to use the REST based endpoint, which was much friendlier to use outside of .NET, but that only provided a small subset of functionality. Web API combines the two by providing an endpoint that’s easy to use regardless of the language and still provides all (with a few limitations currently in v1) the functionality to get things done.

New Features

1. Cross-origin Resource Sharing (CORS) Support Use JavaScript from single-page/mobile applications to access CRM externally.

2. Bound and Unbound Functions – Operations that typically retrieve data that previously required using the Execute message.

3. Bound, Unbound, and Custom Actions – Operations that typically make modifications to the system that previously required using the Execute message.

  • Bound Action = Tied to a specific entity – system defined
  • Unbound Action = Not tied to a specific entitysystem defined
  • Custom Action = Can be bound or unbound – user defined

4. Execute Saved Queries – Retrieve data from system or user defined views.

5. Execute FetchXML – Retrieve data based on a FetchXML query.

6. Batch Operations – Support for ExecuteMutliple to send multiple operations in a single request to the server.

7. Impersonation – Make requests under the context of a different user.

8. Optimistic Concurrency – Check for and handle situations where data on the server might have been modified since it was last retrieved.

9. Discovery Service – Access information about all the instances the user belongs to.

Authentication

In the past, getting authenticated to CRM proved to be almost as big of a task as consuming the web services themselves when not using .NET. Luckily, that changes when using the Web API. One thing that doesn’t change is how JavaScript inside CRM works. You’ll still be authenticated automatically from a web resource so you’ll only need to worry about the changes required based on using the new endpoint.

In order to get started when coming from outside CRM, you’ll first need to register an application with Azure/On-premises Active Directory. This process associates the directory provider (AD) with the application (CRM) and provides another level of security by providing an interface to control permissions to specific applications. The take away from this step is a client ID that will need to be referenced in any application trying to authenticate against Azure/Active Directory to CRM.

Getting authenticated is a breeze thanks to Microsoft’s Azure Active Directory Authentication Libraries (ADAL for short). So long as you use a valid client ID, in most cases you’ll be able to authenticate via interactive mode using the Office 365/AD FS login page or using a fixed set of CRM credentials for integration scenarios. The beauty of using OAuth for authentication is that it allows you to connect from virtually any modern programming language capable of making an HTTP request, the ADAL libraries just simplify the process down to a few lines of code.

Azure Active Directory on GitHub

The authentication process returns a token which needs to be included in the header of future requests, but once you have the token you’re ready to start working with CRM functionality. On a side note, this token will allow you to consume both the new 2016 Web API and 2011 REST endpoints. You can check out the official CRM Web API documentation from the CRM 2016 SDK here.

PowerObjects is your go-to resource for everything CRM 2016! Make sure you check out our other CRM 2016 blogs, webinars, trainings, and events to get the most out of 2016.

Happy CRM’ing!

 

Avatar for JoeCRM

JoeCRM

Joe CRM is a CRM superhero who runs on pure Microsoft Dynamics CRM adrenaline. As the face of PowerObjects, Joe CRM’s mission is to reveal innovative ways to use Dynamics CRM and bring the application to more businesses and organizations around the world.