Node.js example - UserService1.svc/GetEnabledUsers

var request = require('request');

companyKey = 'companyKey'; // Replace the Company Key

// Finding Swimlane
swimlaneFinderUrl = 'https://global.replicon.com/DiscoveryService1.svc/GetTenantEndpointDetails';
swimlaneFinderJsonBody = {};
tenant = {};
tenant['companyKey'] = companyKey;
swimlaneFinderJsonBody['tenant'] = tenant;

swimlaneFinderJsonBody = JSON.stringify(swimlaneFinderJsonBody);

// Using Discovery Call to get the Swimlane info of the Company Key
request({

uri: swimlaneFinderUrl,
method: 'POST',
headers: {'Content-Type' : 'application/json'},
body: swimlaneFinderJsonBody,
timeout: 10000
}, function (error, response, body) {

if (error) {

console.log('Error:', error);
} else if (response.statusCode != 200){

console.log('Error:', response.body);

} else {

swimlaneJsonBody = JSON.parse(body);

swimlane = swimlaneJsonBody.d.applicationRootUrl;
console.log('Swimlane:', swimlane);

allEnabledUserUrl = swimlane + 'services/UserService1.svc/GetEnabledUsers';

jsonBody = JSON.stringify({});

// All Enabled Users Web Service Call
request({

uri: allEnabledUserUrl,
method: 'POST',
headers: {'Content-Type' : 'application/json', 'X-Replicon-Application':'TestCompanykey_ProjectImport_1.0', 'Authorization': 'Bearer lXluv1eGYEGzMwjpsRL5mgEANTNkYTAyZWM5OWU2NDg2MWFmZWVjZDM3MzAxZjA1NTA'},
body: jsonBody,
timeout: 10000
}, function (error, response, body) {

if (error) {

console.log('Error:', error);
} else if (response.statusCode != 200) {

console.log('Error:', response.body);
} else {

enabledUsers = JSON.parse(body)

for (i=0; i<enabledUsers.d.length; i++) {

console.log(enabledUsers.d[i]);
}
};
});
};
});

Related links

Code examples
Introduction to the Replicon API
Using the API
Getting started with Replicon's API
Viewing the available API operations