Skip to main content
1-Visitor
September 8, 2022
Solved

AddStreamEntries error

  • September 8, 2022
  • 1 reply
  • 2147 views

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

Best answer by Sathishkumar_C

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

1 reply

17-Peridot
September 8, 2022
//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

1-Visitor
September 16, 2022

Hi @Sathishkumar_C ,

 

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

 

Thanks,

Sujith

17-Peridot
September 16, 2022

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