Я делюсь примером кода github из этого блога .
При этом используется служба OrganizationData из сценария Node.js для извлечения полного имени контактов (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);
});