【发布时间】:2015-07-27 16:26:18
【问题描述】:
我正在寻找有关如何通过 Node.js 使用 Intel Edison 和 Cumulocity 的示例。是否有可用的 Node.js 示例代码?
【问题讨论】:
标签: node.js intel-edison cumulocity
我正在寻找有关如何通过 Node.js 使用 Intel Edison 和 Cumulocity 的示例。是否有可用的 Node.js 示例代码?
【问题讨论】:
标签: node.js intel-edison cumulocity
您可以在 Node.js 脚本中使用 Cumulocity REST API,如下例所示:
var request = require('request'),
host = 'http://developer.cumulocity.com/',
auth = {
user: 'tenant/user',
pass: 'password',
sendImmediately: true
};
request({
url: host + 'inventory/managedObjects',
auth: auth,
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: {
name: 'My new device',
type: 'My device type',
c8y_IsDevice: {}
},
json: true
});
有关可用端点,请参阅此处的 REST 文档:http://www.cumulocity.com/guides/rest/introduction/。
【讨论】: