web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Getting the Modified data from dynamic CRM on-Prem by using restful/Webapi service

(0) ShareShare
ReportReport
Posted on by

Hi Pankaj.. I have  a question scenario.. Actually I want to get the data from Dynamic CRM on Prem by using a restful service and this dynamic CRM was installed on cloud on a separate virtual machine. what are things that i need to consider while writing a restful service to get the modified data from Dynamic CRM 365 on prem. I have the webapi url from Dynamic CRM and based on that url . does it help anywhere in the programming to get the modified data. ...  Thanks in Advance 

*This post is locked for comments

I have the same question (0)
  • gdas Profile Picture
    50,091 Moderator on at

    Hi,

    What do you mean by modified data ? Please post   your requirement properly,  so that people can answer your question.  

    Did you read your question?

  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at

    Hello,

    As suggested by Goutam, make sure to provide as much as details for your requirement so that someone can help you.

    You can retrieve data based on the modifiedOn field.

  • Community Member Profile Picture
    on at

    I'm new to Dynamic CRM . I have a Webapi url which i got it from developer tools from CRM(on-prem) application which will give the all the entities . If any changes are done in CRM then those changes need to be captured and need to be pulled by using service(this is the requirement ). Here CRM is third part tool for me which is hosted in separate virtual machine . So what are the things that need to consider while writing service and how .  Can Could you please  mail me on my mail id harryankasala@gmail.com

  • Community Member Profile Picture
    on at

    users are using CRM (on-prem)application which they can modified the accounts data . We need to pull the data which are changed for every http request that was made from CRM. I need complete this requirement by using a webapi service. once we filter out this data from CRM through service  we will send this data to logic app--> Service Bus--> Netsuite by using one more service.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    I have done something similar but not using web api. My requirement was that I had to sync my CRM contacts to a third party contacts. To achieve this,

    1. I created a field in Contact entity first which is used to store the Guid of the other system. I was using this later to determine that if I need to create a record or update it.

    2. I also created a separate custom entity (Integration) with the field like entity id, entity name, message (Create/Update) & Status.

    3. Then I created a plugin on contact create & update which created the record on my custom entity. That is whenever the record is created/updated,  I create a record in my custom entity.

    4. Now that I have the data in my custom entity which gives me all the records which are created and updated, I create a console application to retieve the details and then push it to my third party system.

    Basically the hard part is to determine which records are changed. Once you have that data you can then create console app to push that data directly to your thirsd party or you can create a middleware wcf service which connects to CRM, retrieves this changed data and returns it to the caller. You could configure this wcf service as restfull if that's your requirement. Its upto you how you design and what best suits your needs. Above is just one way of doing this and I am sure there must be several other ways as well.

    Hope this helps.

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi,

    What I understand from you that you need pull data which are changing in CRM will be sync with your custom tool/portal. Following are the steps, guideline you could follow.

    1) Maintain Common GUID / unique key to identify data both the system.

    2)

    CRM => External System

    Expose Rest/ Soap services to push the data to your to external system from CRM.

    When you want those changed data ? Is this real time or certain interval. If this is real time then you should write plugins in each entity where you push the data for any kind of modifications and creation in CRM by consuming external system services inside plugin or workflow. You should update or create using  GUID / unique key to sync the data to external system

    OR

    External System=> CRM

    If you don't want to change anything in the CRM and you only want to use WEB API ,so you need to go for batch process / console application which will be responsible to sync data to your external system certain interval.

    By doing this user may not view real time data from external system. So what you can do you can pull the data using the unique key / GUID and modified on field from your CRM TO external  system each time when user requests certain data to view in the external system.

    Hope this helps.

  • Community Member Profile Picture
    on at

    Thanks for the response.. Ravi , Goutam, Mahender ... Actually the procedure written by goutam i'm following right now.. when I'm trying to solve the first step i'm having trouble .. My webapi returning all the entities when i run without filtering Primary key value. but when i'm trying to query by using GUID then i'm not getting any result...

    Here is the path GET [Organization URI]/api/data/v8.2/accounts?userQuery=766b0101-5044-e611-80d3-000d3a918c4d

    I tried with accountid inplace of userquery even no luck...

    {

     "error":{

       "code":"","message":"Syntax error at position 10 in 'AccountId=9fe17aa2-e5a2-e711-80fd-000d3a91d738'.","innererror":{

         "message":"Syntax error at position 10 in 'AccountId=9fe17aa2-e5a2-e711-80fd-000d3a91d738'.","type":"Microsoft.OData.Core.ODataException","stacktrace":"   at Microsoft.OData.Core.UriParser.ExpressionLexer.ValidateToken(ExpressionTokenKind t)\r\n   at Microsoft.OData.Core.UriParser.Parsers.UriQueryExpressionParser.ParseExpressionText(String expressionText)\r\n   at Microsoft.OData.Core.UriParser.ODataQueryOptionParser.ParseFilterImplementation(String filter, ODataUriParserConfiguration configuration, IEdmType elementType, IEdmNavigationSource navigationSource)\r\n   at Microsoft.OData.Core.UriParser.ODataQueryOptionParser.ParseFilter()\r\n   at System.Web.OData.Query.FilterQueryOption.get_FilterClause()\r\n   at Microsoft.Crm.Extensibility.OData.DataQueryOptionsConverter.SetFilterExpression(QueryExpression qe, FilterQueryOption filterQueryOption)\r\n   at Microsoft.Crm.Extensibility.OData.QueryOptionsConverterBase`4.GetQueryExpression(ODataQueryOptions queryOptions, String edmEntityName, CrmODataExecutionContext context)\r\n   at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.RetrieveEdmEntityCollection(CrmODataExecutionContext context, String entityCollectionName, String castedEntityName, ODataQueryOptions queryOptions)\r\n   at Microsoft.Crm.Extensibility.OData.EntityController.GetEntitySetInternal(String entitySetName, String castEntityName, CrmODataExecutionContext context, CrmEdmEntityObjectCollection crmEdmEntityObjectCollection, ODataQueryOptions queryOptions)\r\n   at Microsoft.Crm.Extensibility.OData.EntityController.GetEntitySet(String entitySetName)\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"

       }

     }

    }

    I have that record in my entity..

    "@odata.etag":"W/\"3353205\"","customertypecode":100000000,"address2_addresstypecode":1,"merged":false,"statecode":0,"exchangerate":1.0000000000,"name":"Franchise 474","statuscode":1,"modifiedon":"2017-12-01T18:22:46Z","_owninguser_value":"369c3eea-a3f7-e511-80cb-000d3a913664","hisc_peaqtrackingsurveyparticipant":true,"donotpostalmail":false,"accountratingcode":1,"donotphone":false,"hisc_peaqannualsurveyparticipant":false,"preferredcontactmethodcode":1,"_ownerid_value":"369c3eea-a3f7-e511-80cb-000d3a913664","customersizecode":1,"hisc_newfranchsienumber":474,"openrevenue_date":"2018-12-05T21:59:37Z","businesstypecode":1,"donotemail":false,"address2_shippingmethodcode":1,"address1_addressid":"e51072d4-65ef-4468-a634-89dfaaa6535e","address2_freighttermscode":1,"_hisc_primarylocation_value":null,"createdon":"2017-09-26T18:08:22Z","versionnumber":3353205,"donotbulkemail":false,"opendeals_date":"2018-12-05T21:59:37Z","donotfax":false,"hisc_isprimarylocation":false,"donotbulkpostalmail":false,"donotsendmm":false,"hisc_satelliteoffice":false,"creditonhold":false,"_transactioncurrencyid_value":"bdc0cdd6-a4f7-e511-80cb-000d3a913664","accountid":"9fe17aa2-e5a2-e711-80fd-000d3a91d738"

    I tried by using different GUID values from the entity..

    any help would be appreciated ...

  • Community Member Profile Picture
    on at

    tried this one too

    https:// org name/api/data/v8.2/accounts?AccountId=9fe17aa2-e5a2-e711-80fd-000d3a91d738

    {

     "error":{

       "code":"","message":"The query parameter AccountId is not supported","innererror":{

         "message":"The query parameter AccountId is not supported","type":"Microsoft.Crm.CrmHttpException","stacktrace":"   at Microsoft.Crm.Extensibility.OData.QueryOptionsConverterBase`4.ThrowIfInvalidQueryOptionsExists(CrmODataExecutionContext context)\r\n   at Microsoft.Crm.Extensibility.OData.QueryOptionsConverterBase`4.GetQueryExpression(ODataQueryOptions queryOptions, String edmEntityName, CrmODataExecutionContext context)\r\n   at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.RetrieveEdmEntityCollection(CrmODataExecutionContext context, String entityCollectionName, String castedEntityName, ODataQueryOptions queryOptions)\r\n   at Microsoft.Crm.Extensibility.OData.EntityController.GetEntitySetInternal(String entitySetName, String castEntityName, CrmODataExecutionContext context, CrmEdmEntityObjectCollection crmEdmEntityObjectCollection, ODataQueryOptions queryOptions)\r\n   at Microsoft.Crm.Extensibility.OData.EntityController.GetEntitySet(String entitySetName)\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"

       }

     }

    }

  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Hari,

    You need to use endpoint like below -

    https://crmorg/api/data/v8.2/accounts(9fe17aa2-e5a2-e711-80fd-000d3a91d738)

    Hope this helps.

    Also, when you get answer to your main question do remember to close the thread by marking the helpful suggestion as answer and open new thread for your new questions/queries. This will ensure that you get responses from other community member as well.

  • Verified answer
    Community Member Profile Picture
    on at

    Thanks Kashyap.. it's working ..as I'm new to the development i didn't see where to close this thread...

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans