Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
Hi everyone,
I have create a service which take input json and save into stream. For this I have created a stream and data_shape.
script
// tags:TAGS
var tags = new Array();
// timestamp:DATETIME
var timestamp = new Date();
// values:INFOTABLE(Datashape: rok_data_shape)
var values = Things["rok_stream"].CreateValues();
values.id = id; //NUMBER
values.name = name; //STRING
// location:LOCATION
var location = new Object();
location.latitude = 0;
location.longitude = 0;
location.elevation = 0;
location.units ="WGS84";
var params = {
tags : tags,
timestamp : timestamp,
source : me.name,
values : values,
location : location
};
// AddStreamEntry(tags:TAGS, timestamp:DATETIME, source:STRING("me.name"), values:INFOTABLE(rok_data_shape), location:LOCATION):NOTHING
Things["rok_stream"].AddStreamEntry(params);
My service is working fine. with input { "id" : 1, "name": "Foo"} and data save in stream. But I want give multiple record in single rest call. example - I want to post [{ "id" : 1, "name": "Foo"}, { "id" : 1, "name": "Bar"}]. How I can post json array to the service.
When you retrieve a JSON Array, Thingworx will automatically add array
So you'll need to do: postedData.array.id something like that.
now if you are invoking and posting to Thingworx I believe it does it as well, if not, then of course just do postedData.id