Skip to main content
Sep 8, 2022 8:51 AM UTC
Solved

AddStreamEntries error

Hi all,

 

Getting error while executing AddStreamEntries service: 

JavaException: java.lang.Exception: Invalid number of values provided to AddStreamEntry

 

 

 

let newEntry = {
		sourceType: undefined, // STRING
		values: entries, // INFOTABLE
		location: undefined, // LOCATION
		source: undefined, // STRING
		tags: undefined, // TAGS
		timestamp: new Date() // DATETIME
	};
	// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(StreamEntryWithValues)
	let obj = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
		infoTableName: "InfoTable",
		dataShapeName: "StreamEntryWithValues"
	});
	obj.AddRow(newEntry);

	me.AddStreamEntries({
		values: obj /* INFOTABLE {"dataShape":"StreamEntryWithValues"} */
	});

 

 

 

Thanks,

Sujith

Sep 16, 2022 8:22 AM UTC

use below service

 

Things["TestStream"].AddStreamEntries({
	values: dataset/* INFOTABLE */
});

 

"dataset" is the nested infotable as below, which uses "StreamEntryWithValues" datashape.

Sathishkumar_C_0-1663316212953.png

In "StreamEntryWithValues" datashape, there is one infotable field called "values" 

In "values" infotable, you will have your own data set.

Each row consider as one entry in stream.

 

Hope it helps

6 replies

Sep 8, 2022 11:01 AM UTC
//TestValuestream is the value stream name

let values = Things["TestValuestream"].CreateValues();
values.x = new Date(); //your datashape fields
values.y = 10; //your datashape fields
let params = {
 tags: undefined,
 timestamp: new Date(),
 source: me.name,
 values: values,
 location: undefined
};
Things["TestValuestream"].AddStreamEntry(params);

result = values;

 

try above code

Sep 16, 2022 6:51 AM UTC

Hi @Sathishkumar_C ,

 

I want to add multiple entries to the Stream at once, not only one entry.

 

Thanks,

Sujith

Sep 16, 2022 8:22 AM UTC

use below service

 

Things["TestStream"].AddStreamEntries({
	values: dataset/* INFOTABLE */
});

 

"dataset" is the nested infotable as below, which uses "StreamEntryWithValues" datashape.

Sathishkumar_C_0-1663316212953.png

In "StreamEntryWithValues" datashape, there is one infotable field called "values" 

In "values" infotable, you will have your own data set.

Each row consider as one entry in stream.

 

Hope it helps