Hi Sasa,
There is no way to configure the HTTP publisher to send arbitrary JSON in its body.
Depending on the requirements of your situation, you may be able to achieve this with the TCP/IP data source. If the responses to the posts aren't especially important, and if getting data synchronized isn't especially important, meaning live data is the focus, I think TCP/IP and a script could be an adequate solution. I don't know how many values/second you could get, though... hopefully several hundred or thousand.
You'd want a TCP/IP data source, pointed at the IP or host and port that you are wishing to POST data to. Create a single data point on this data source, let's call it "dataOut". Properties;
Datatype: Alphanumeric
Queryable: Unchecked
Read Command:
Value Regex: .* //Also, you could consider using something that catches \n
Value Index: 0
Settable: Checked
Write Command: %VALUE%
Now you'll want a scripting data source, running on a cron, with one or more points to be published and also dataOut in context. I've presumed the service we're publishing to accepts batches, but the logic of it all should be similar regardless.
var pointsToPublish = [p1, p2, p3]
var startTime = new Date().getTime() - 1000; //This is related to the cron of the script
function buildPost(jsonBody) {
//Adjust your Host for sure, but you may need additional headers
return "POST /dataEndpoint HTTP/1.1\nUser-Agent: Sasa custom publisher\nContent-Length: " + jsonBody.length +
"\nContent-Type: application/json\nHost: localhost:1234\n\n" + jsonBody;
}
for(var p = 0; p < pointsToPublish.length; p+=1) {
var values = pointsToPublish[p].getValuesSince(startTime);
var queue = []
for(var k = 0; k < values.length; k+=1) {
queue.push({
"identifier": "1",
"timestamp": String(values[k].time),
"value" : String(values[k].value),
"type" : "27",
"status" : "1",
"smgwid" : "1",
"obis" : "1-0:1.8.0",
"validation": "xyz"
});
}
dataOut.set(buildPost(JSON.stringify(queue)));
}
This script would be running on a cron like 0/1 * * * * ? but this may cause problems. The Timeout for the TCP/IP data source will be limitting for each dataOut.set() call, so you'll want the cron to perhaps be 0/5, then the startTime to be now-5000 such that you can send 15 messages with a 300 ms timeout with some extra wiggle room. Just watch for aborted polls of the Scripting data source, and adjust accordingly.