[英]How to connect organization data service of dynamics crm with node.js application
How do I connect to the organization data service of Dynamics CRM with a node.js application? 如何使用node.js应用程序连接到Dynamics CRM的组织数据服务?
I do not have web api in developer resource, so how to get data with organization data service? 我在开发人员资源中没有Web API,那么如何使用组织数据服务获取数据?
... ...
If you are using CRM 2016 or later Use the Microsoft Dynamics 365 Web API 如果您使用的是CRM 2016或更高版本, 请使用Microsoft Dynamics 365 Web API
The Web API, which is new for Microsoft Dynamics 365 (online & on-premises), provides a development experience that can be used across a wide variety of programming languages, platforms, and devices. Web API是Microsoft Dynamics 365(在线和本地)的新增功能,可提供可在多种编程语言,平台和设备上使用的开发体验。 The Web API implements the OData (Open Data Protocol), version 4.0, an OASIS standard for building and consuming RESTful APIs over rich data sources. Web API实现了OData(开放数据协议)版本4.0,这是用于通过丰富数据源构建和使用RESTful API的OASIS标准。
Because the Web API is built on open standards, we don't provide assemblies for a specific developer experience. 由于Web API是基于开放标准构建的,因此我们不提供针对特定开发人员体验的程序集。 You can compose HTTP requests for specific operations or use third-party libraries to generate classes for whatever language or platform you want. 您可以为特定操作编写HTTP请求,也可以使用第三方库为所需的任何语言或平台生成类。
If you are using CRM 2015 or earlier use the Organization Service (aka SOAP endpoint) . 如果您使用的是CRM 2015或更早版本,请使用Organization Service(又名SOAP端点) 。
Available since CRM 2011 the service provided a classic SOAP endpoint and is probably the most commonly used web service. 自2011年CRM开始可用,该服务提供了经典的SOAP端点,并且可能是最常用的Web服务。 This service provides access to the full range of 365 operations, and messages. 该服务提供对全部365种操作和消息的访问。 For .Net developers the SDK provides a set of assemblies that mean using the service is simple with the complexities of the SOAP endpoint abstracted away. 对于.Net开发人员,SDK提供了一组程序集,这意味着使用该服务非常简单,并且抽象出了SOAP端点的复杂性。 Non-.Net developers have a more challenging environment and they must communicate directly with the SOAP endpoint which is typically a far more complicated affair. 非.Net开发人员的环境更具挑战性,他们必须直接与SOAP端点进行通信,而SOAP端点通常是一件更为复杂的事情。
Am sharing the github code sample from this blog . 正在共享此博客中的github代码示例。
This uses OrganizationData service from Node.js script to pull FullName of Contacts (ContactSet). 这使用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.