如何将Dynamics CRM的组织数据服务与node.js应用程序连接起来 [英] How to connect organization data service of dynamics crm with node.js application

查看:21
本文介绍了如何将Dynamics CRM的组织数据服务与node.js应用程序连接起来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用node.js应用程序连接到Dynamics CRM的组织数据服务?

我的开发者资源没有web API,如何通过组织数据服务获取数据?

..。

推荐答案

我正在共享this blog中的gihub代码示例。

这使用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);
    });

这篇关于如何将Dynamics CRM的组织数据服务与node.js应用程序连接起来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆