Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Thingworx REST API POST example for executing a service
- // Request datastream values generated by my container things.
- // thing property URI example
- var url = 'https://aca-karelia01.elisaiot.com/Thingworx/Things/Roman%20Theatre%20of%20Cartagena/Properties/people_entered';
- var util = require('util');
- console.log('Get value from Thingworx Thing property url = ' + url);
- var Client = require('node-rest-client').Client;
- // configure basic http auth for every request
- var options_auth={
- user:"LTTNS12",
- password:"changeit"
- };
- client = new Client(options_auth);
- args ={
- headers:{
- "Accept":"application/json",
- "Content-Type":"application/json"
- },
- data:{
- "people_entered":"6" //only 5 lines in the demo
- },
- requestConfig:{
- timeout:1000, //request timeout in milliseconds
- keepAlive:false, //Enable/disable keep-alive functionalityidle socket.
- }
- };
- // use POST for executing service
- client.put(url, args, function(data, response){
- }).on('error',function(err){
- console.log('something went wrong on the request', err.request.options);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement