Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

PowerObjects Blog 

for Microsoft Business Applications


Start Your Engines: Getting Started with the CRM 2016 Web API

Post Author: Joe D365 |

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.

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!

 

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

7 comments on “Start Your Engines: Getting Started with the CRM 2016 Web API”

  1. Hello,

    I need to authenticate to CRM 2016 to use the new REST API, what things I need to do ?
    Also the Azure Active Directory for php language are not provided

    1. Also I don't have access to the CRM 2016 but I collaborate with them to achieve that.

    2. Hi !

      I have the exactly same issue as you !
      If you found a solution, I am still aware.. !

      Thanks

  2. Hi Joe,

    If I want to connect to MSCRM onpremise IFD organization to perform curd operation from a service developed for mobile application can I use the Webapi in mobile app service??? Does it require Mobile app to be installed in the Azure cloud to get the client id??

    External application connection establishment is little unclear , could you please clarify.

    Regards,
    Santhi

  3. Hi Joe,
    I want to make changes to the CRM web api to allow me to search for entities that have a colon in the private key. Specifically I have read that changing the requestpathinvalidcharacters properties will work. Is this achievable with Dynamics 365 online? Regards,

PowerObjects Recommends