Использование Intel Edison и Node.js с Cumulocity

Я ищу пример использования Intel Edison с Cumulocity через Node.js. Доступен ли пример кода Node.js?


person André    schedule 26.07.2015    source источник


Ответы (1)


Вы можете использовать Cumulocity REST API в скрипте Node.js, как в следующем примере:

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/.

person user485332    schedule 27.07.2015