Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Notifications
Login / Register
Schneider Electric
Community
Community
Notifications
close
  • Categories
  • Forums
  • Knowledge Center
  • Blogs
  • Ideas
  • Events & Webinars
Help
Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Login / Register

Contact Support

Close

Ask our Experts

Have a question related to our products, solutions or services? Get quick support on community Forums

Email Us

For Community platform-related support, please email us

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).

Example usage of HTTPLib_POST (HTTPLib)

HVAC and Pumping Forum

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

Improve your search experience:

  • Exact phrase → Use quotes " " (e.g., "error 404")
  • Wildcard → Use * for partial words (e.g., build*, *tion)
  • AND / OR → Combine keywords (e.g., login AND error, login OR sign‑in)
  • Keep it short → Use 2–3 relevant words , not full sentences
  • Filters → Narrow results by section (Knowledge Base, Users, Products)
cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Select a Country

Please select a country to continue with beta search.

  • Home
  • Schneider Electric Community
  • Industrial Automation
  • HVAC and Pumping Forum
  • Example usage of HTTPLib_POST (HTTPLib)
Options
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page
Invite a Co-worker
Send a co-worker an invite to the portal.Just enter their email address and we'll connect them to register. After joining, they will belong to the same company.
You have entered an invalid email address. Please re-enter the email address.
This co-worker has already been invited to the Exchange portal. Please invite another co-worker.
Please enter email address
Send Invite Cancel
Invitation Sent
Your invitation was sent.Thanks for sharing Exchange with your co-worker.
Send New Invite Close
Top Experts
User Count
FedericoM
FedericoM Mentor
119
Bastian_Schmitz
Bastian_Schmitz Champion
64
M_Cervati
M_Cervati Troubleshooter
18
View All

Recommended Forums

  • Industry Automation and Control Forum

  • Machine and Motion Control Forum

  • Alliance Partner Program System Integrator

Invite a Colleague

Found this content useful? Share it with a Colleague!

Invite a Colleague Invite
Solved Go to Solution
Back to HVAC and Pumping Forum
Start a Topic
Solved
KrzysztofSoczewka
KrzysztofSoczewka
Contributor

Posted: ‎2026-07-12 11:46 PM

0 Likes
4
367
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2026-07-12 11:46 PM

Example usage of HTTPLib_POST (HTTPLib)

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:

  1. Write the JSON to a file first (e.g. HTTPLib_SaveBinaryFile)
  2. Pass that filename via srcFilename in HTTPLib_POST
  3. Read responseStatusCode / responseBody once done is TRUE

This works for me, but I'd like to confirm:

  • Is file-based body really the only intended method, or is there a variant/way to pass the body as a string directly?
  • Is there an official example project showing HTTPLib_POST with a JSON body?

Any pointers would be appreciated. Thanks!

Labels
  • Labels:
  • HVAC
  • Tags:
  • english
Reply

Link copied. Please paste this link to share this article on your social media post.

  • All forum topics
  • Previous Topic
  • Next Topic

Accepted Solutions
williamFolle
williamFolle Contributor
Contributor

Posted: ‎2026-07-17 03:08 AM

In response to KrzysztofSoczewka
0 Likes
0
310
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

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.

See Answer In Context

Reply

Link copied. Please paste this link to share this article on your social media post.

Replies 4
MargheritaM
MargheritaM Contributor
Contributor

Posted: ‎2026-07-14 02:53 AM

0 Likes
2
341
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

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

Reply

Link copied. Please paste this link to share this article on your social media post.

KrzysztofSoczewka
KrzysztofSoczewka
Contributor

Posted: ‎2026-07-16 04:49 AM

In response to MargheritaM
0 Likes
1
324
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

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?

Reply

Link copied. Please paste this link to share this article on your social media post.

williamFolle
williamFolle Contributor
Contributor

Posted: ‎2026-07-17 03:08 AM

In response to KrzysztofSoczewka
0 Likes
0
311
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

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.

Reply

Link copied. Please paste this link to share this article on your social media post.

FedericoM
FedericoM Mentor
Mentor

Posted: ‎2026-07-17 06:58 AM

0 Likes
0
303
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

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

FedericoM_0-1784296650923.png

 

Reply

Link copied. Please paste this link to share this article on your social media post.

Preview Exit Preview

never-displayed

You must be signed in to add attachments

never-displayed

 

You’ve reached the end of your document

WHAT’S NEXT?

Ask our Experts

Didn't find what you are looking for? Ask our experts!

My Dashboard

Check out the new Feeds and activities that are relevant to you.

To The Top!

Forums

  • APC UPS Data Center Backup Solutions
  • EcoStruxure IT
  • EcoStruxure Geo SCADA Expert
  • Metering & Power Quality
  • Schneider Electric Wiser

Knowledge Center

Events & webinars

Ideas

Blogs

Get Started

  • Ask the Community
  • Community Guidelines
  • Community User Guide
  • How-To & Best Practice
  • Experts Leaderboard
  • Contact Support

    Ask our Experts

    Have a question related to our products, solutions or services? Get quick support on community Forums

    Email Us

    For Community platform-related support, please email us

Subscribing is a smart move!
You can subscribe to this board after you log in or create your free account.
Forum-Icon

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.

Register today for FREE

Register Now

Already have an account? Login

Terms & Conditions Privacy Notice Change your Cookie Settings © 2026 Schneider Electric

Welcome!

Welcome to your new personalized space.

of

Explore