簡體   English   中英

如何將Dynamics CRM的組織數據服務與Node.js應用程序連接

[英]How to connect organization data service of dynamics crm with node.js application

如何使用node.js應用程序連接到Dynamics CRM的組織數據服務?

我在開發人員資源中沒有Web API,那么如何使用組織數據服務獲取數據?

動態crm版本iamge ... 開發人員資源圖片

如果您使用的是CRM 2016或更高版本, 請使用Microsoft Dynamics 365 Web API

Web API是Microsoft Dynamics 365(在線和本地)的新增功能,可提供可在多種編程語言,平台和設備上使用的開發體驗。 Web API實現了OData(開放數據協議)版本4.0,這是用於通過豐富數據源構建和使用RESTful API的OASIS標准。

由於Web API是基於開放標准構建的,因此我們不提供針對特定開發人員體驗的程序集。 您可以為特定操作編寫HTTP請求,也可以使用第三方庫為所需的任何語言或平台生成類。

如果您使用的是CRM 2015或更早版本,請使用Organization Service(又名SOAP端點)

自2011年CRM開始可用,該服務提供了經典的SOAP端點,並且可能是最常用的Web服務。 該服務提供對全部365種操作和消息的訪問。 對於.Net開發人員,SDK提供了一組程序集,這意味着使用該服務非常簡單,並且抽象出了SOAP端點的復雜性。 非.Net開發人員的環境更具挑戰性,他們必須直接與SOAP端點進行通信,而SOAP端點通常是一件更為復雜的事情。

正在共享此博客中的github代碼示例。

這使用Node.js腳本中的OrganizationData服務來提取聯系人的全名(ContactSet)。

    // Set the headers for the call to CRM
    var headers = {
      'Authorization': 'Bearer ' + sess.access_token, //send the oauth access token to authenticate
      'Accept': 'application/json' //tell CRM to send json data back
    }

    //configure the CRM odata request
    var options = {
      host : crm_host,
      port : crm_port,
      path : '/XRMServices/2011/OrganizationData.svc/ContactSet?$select=FullName', //hardcoded to select just the contact name
      method : 'GET',
      rejectUnauthorized: false,//to allow for self-signed SSL certificates - use at your own risk!!!
      headers : headers //set in the previous step
    };
    
    var reqGet = https.request(options, function(resGet) {
      //should do something here if we get 'www-authenticate': 'Bearer error' response headers
      //console.log("headers: ", resGet.headers);
      
      resGet.on('data', function(d) {
        //console.info('raw response: ' + d);
        var json = JSON.parse(d);
        var records = json.d.results;
        
        //console.info('results: ' + JSON.stringify(records));
        for (var i in records) {   
          res.write(records[i].FullName + '<br />');
        }
        res.write('</body>');
        res.write('</html>');
        res.end();
      });
    });
    reqGet.end();
    
    //handle errors
    reqGet.on('error', function(e) {
      console.error(e);
    });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM