Advertisement
Guest User

Untitled

a guest
Feb 17th, 2016
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. // Thingworx REST API POST example for executing a service
  2. // Request datastream values generated by my container things.
  3.  
  4. // thing property URI example
  5. var url = 'https://aca-karelia01.elisaiot.com/Thingworx/Things/Roman%20Theatre%20of%20Cartagena/Properties/people_entered';
  6. var util = require('util');
  7.  
  8. console.log('Get value from Thingworx Thing property url = ' + url);
  9.  
  10. var Client = require('node-rest-client').Client;
  11.  
  12. // configure basic http auth for every request
  13. var options_auth={
  14. user:"LTTNS12",
  15. password:"changeit"
  16. };
  17.  
  18. client = new Client(options_auth);
  19.  
  20. args ={
  21. headers:{
  22. "Accept":"application/json",
  23. "Content-Type":"application/json"
  24. },
  25. data:{
  26. "people_entered":"6" //only 5 lines in the demo
  27. },
  28. requestConfig:{
  29. timeout:1000, //request timeout in milliseconds
  30. keepAlive:false, //Enable/disable keep-alive functionalityidle socket.
  31. }
  32. };
  33.  
  34. // use POST for executing service
  35. client.put(url, args, function(data, response){
  36. }).on('error',function(err){
  37. console.log('something went wrong on the request', err.request.options);
  38. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement