How to run Kepware IOT Gateway APIs in Thingworx services
Hi,
I am trying to update Kepware Tag through API call from IOT Gateway setup.
Refering the document in http://127.0.0.1:39320/iotgateway/
I am using this API
| http://127.0.0.1:39320/iotgateway/write |
to update a tag. Based on the example given, I was able to successfully run the API through Postman but unable to run it through Thingworx API.
cURL example given in the doc:
curl -H "Content-Type: application/json" -vX POST -d "[{ \"id\": \"Channel1.Device1.tag1\", \"v\": 42},{ \"id\": \"Channel1.Device1.tag2\", \"v\": 17},{ \"id\": \"Channel1.Device1.tag3\", \"v\": 36}]" http://127.0.0.1:39320/iotgateway/write
In postman which is on same server:
(POST) http://127.0.0.1:39320/iotgateway/write
input in json format :
Thingworx server on the same instance
try{
var Obj = [{'id': 'Channel1.Device1.status','v': 1}];
let params = {
proxyScheme: undefined /* STRING {"defaultValue":"http"} */,
headers: {'Content-Type': 'application/json'} /* JSON */, // also tried keeping it as undefined
ignoreSSLErrors: undefined /* BOOLEAN */,
useNTLM: undefined /* BOOLEAN {"defaultValue":false} */,
workstation: undefined /* STRING {"defaultValue":""} */,
useProxy: undefined /* BOOLEAN {"defaultValue":false} */,
withCookies: undefined /* BOOLEAN {"defaultValue":false} */,
proxyHost: undefined /* STRING {"defaultValue":""} */,
url: "http://127.0.0.1:39320/iotgateway/write" /* STRING */,
content: Obj /* JSON */,
timeout: undefined /* NUMBER {"defaultValue":60} */,
proxyPort: undefined /* INTEGER {"defaultValue":8080} */,
password: undefined /* STRING */,
domain: undefined /* STRING {"defaultValue":""} */,
username: undefined /* STRING */
};
// result: JSON
var result = Resources["ContentLoaderFunctions"].PostJSON(params);
} catch(err){
// result = err;
}
Output (Type Json) : Service execution failed. An input value is required.
I fond a post and also tried to run the cURL in the service, but it didnt work.
let params = {
proxyScheme: undefined /* STRING {"defaultValue":"http"} */,
headers: undefined /* JSON */,
ignoreSSLErrors: undefined /* BOOLEAN */,
useNTLM: undefined /* BOOLEAN {"defaultValue":false} */,
workstation: undefined /* STRING {"defaultValue":""} */,
useProxy: undefined /* BOOLEAN {"defaultValue":false} */,
withCookies: undefined /* BOOLEAN {"defaultValue":false} */,
proxyHost: undefined /* STRING {"defaultValue":""} */,
url: 'curl -H "Content-Type: application/json" -vX POST -d "[{ \"id\": \"Channel1.Device1.status\", \"v\": 1}]" http://127.0.0.1:39320/iotgateway/write' /* STRING */,
timeout: undefined /* NUMBER {"defaultValue":60} */,
appendHeader: undefined /* BOOLEAN {"defaultValue":true} */,
proxyPort: undefined /* INTEGER {"defaultValue":8080} */,
password: undefined /* STRING */,
domain: undefined /* STRING {"defaultValue":""} */,
username: undefined /* STRING */
};
// result: STRING
let result = Resources["ContentLoaderFunctions"].LoadText(params);
So how do i work with this API in service.
Thanks

