Web API for CRM
Champs,
You might
went through this link, which is introducing WEB API for Dynamics CRM Online 2015 Update 1.
Microsoft
Dynamics CRM Web API Preview :
What about if you need this features in earlier
versions of CRM?
Do you want a work around to achieve this?
As you know the CRM Organization Data Service can access from Web resources within the CRM
context without specific authentications.
What about accessing from an application outside CRM context?
Here is my thought on this.
Create a wrapper WEB API which will internally use CRM assemblies to process data.
Create a wrapper WEB API which will internally use CRM assemblies to process data.
Application -> WEB API -> CRM API
In ideal path we have to connect Web API to DB server. Since that is
unsupported we will go through WCF layer
Now let us create one Web API Application:
Now let us create one Web API Application:
Create a controller.
for sample process we will create a controller called AccountController.
for sample process we will create a controller called AccountController.
You have full control of defining the method as you like. I assume
you have already have some knowledge on Web API.
We will more consider on the Web API authentication
process.
Authentication is a
fundamental aspect of security that involves verifying credentials supplied by
a user to establish an identity for the user in an application.
Even though there are multiple methods, we will use preshared key as an authentication
mechanism
Lets create a handler in Web API project as below
Lets create a handler in Web API project as below
Public Keys and Private
keys are hard coded to make it simple, you can have your own style to adapt
private and public keys.
Here we will register the handler in
Global.asax file
Now You are
ready with CRM web API with preshared key authentication.
While we access this Web API from Smartphone, Tablet, IOT or any other web browsers we have to pass authentication at header as below.
Ex: Lets us have a sample using HttpClient.
Happy Coding!
Comments