Ask our Experts
Didn't find what you are looking for? Ask our experts!
New Community Ranking System
Our Community ranking system has recently been updated. You may notice changes in user rankings and receive system messages or notifications. If you have questions about how the new ranking works, please refer to the announcement post for more details (click here).
Support Forum for HVAC and pumping machines, Modicon M17x and EcoStruxure Machine Expert HVAC software for chillers, AHU, CRAC units for datacenters or process chillers applications - from design, implementation to troubleshooting and more, by Schneider Electric.
Search in
Please select a country to continue with beta search.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2026-07-12 11:46 PM
I'm using HTTPLib_POST (HTTPLib library, embedded target) to send a JSON body to an external HTTP API.
Looking at the inputs, reqHeaders (STRING[2047]) accepts headers directly as a string, but there's no direct string input for the body – only srcFilename ("Source filename to be posted as body"). So the only way seems to be:
HTTPLib_SaveBinaryFile)srcFilename in HTTPLib_POSTresponseStatusCode / responseBody once done is TRUEThis works for me, but I'd like to confirm:
HTTPLib_POST with a JSON body?Any pointers would be appreciated. Thanks!
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2026-07-17 03:08 AM
Hello, yes, I can confirm that you only need to specify the name of the document you created.
In your case,
srcFilename := 'loki_body.json';
should be enough to make everything work.
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2026-07-14 02:53 AM
Hello,
unfortunatelly there isn't a way to pass the body with a STRING, you have to use a file which results more flexible in terms of dimensions.
Regarding an example project, we are working on an example showing how to use HTTP GET, POST, DELETE and PATCH. It will be released in the following weeks.
Margherita
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2026-07-16 04:49 AM
It's my code
count := count + 1;
IF count = 100 THEN
Start := TRUE;
count := 0;
END_IF;
epochSec := GetEpochTime_s();
refresh_post(enable := TRUE, period := period1);
trigEdge(clk := refresh_post.out);
IF trigEdge.q AND seq = 0 THEN
deleteResult := HTTPLib_DeleteFile(filename := bodyFile);
url1 := 'https://logs-prod-043.grafana.net/loki/api/v1/push';
reqHeaders1 := 'Authorization: Basic MTY2NzI2OTpnbxxxxxxxx';
reqHeaders1 := CONCAT(reqHeaders1, '$R$N');
reqHeaders1 := CONCAT(reqHeaders1, 'Content-Type: application/json');
jsonBody := '{"streams":[{"stream":{"job":"plc","device":"PLC1"},"values":[["';
epochStr := TO_STRING(epochSec);
epochStr := CONCAT(epochStr, '000000000');
jsonBody := CONCAT(jsonBody, epochStr);
jsonBody := CONCAT(jsonBody, '","temperatura=');
valStr := TO_STRING(v08740);
jsonBody := CONCAT(jsonBody, valStr);
jsonBody := CONCAT(jsonBody, '"]]}]}');
saveResult := HTTPLib_SaveBinaryFile(
filename := bodyFile,
inBuff := ADR(jsonBody),
buffSize := LEN(jsonBody)
);
IF saveResult = 0 THEN
enablePost := TRUE;
seq := 1;
END_IF;
END_IF;
//
post1(
enable := enablePost,
url := url1,
srcFilename := '/SD/loki_body.json',
reqHeaders := reqHeaders1,
tls := TRUE,
allowIfServerNotVerified := FALSE
);
postTimeout(in := (seq = 1), pt := 5000);
IF post1.done OR postTimeout.q THEN
IF post1.done THEN
statusCode := post1.responseStatusCode;
responseBody := post1.responseBody;
END_IF;
enablePost := FALSE;
seq := 0;
postTimeout(in := FALSE); // reset timera
END_IF;
Start := FALSE;
I think the problem may be caused by an incorrect file path: srcFilename := '/SD/loki_body.json';. What path should be used?
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2026-07-17 03:08 AM
Hello, yes, I can confirm that you only need to specify the name of the document you created.
In your case,
srcFilename := 'loki_body.json';
should be enough to make everything work.
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2026-07-17 06:58 AM
The http functions working on files use a private internal filesystem, filename is enough
Link copied. Please paste this link to share this article on your social media post.
You’ve reached the end of your document
Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.