curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder Daniel himself.

How to use libcurl to POST data in JSON-format

From: Владислав Коробов via curl-library <curl-library_at_lists.haxx.se>
Date: Wed, 18 Jun 2025 11:47:58 +0300

Hello everyone,
I work on Linux #astra31+ci49-Ubuntu with  GNU/Linux. 
On my system installed curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1k zlib/1.2.11 brotli/1.0.7 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) libssh2/1.11.0 nghttp2/1.36.0 librtmp/2.3.
From this system I can get the data from some device usung console request to the private https server via the curl command:
 
curl -k -X GET -H 'Authorization: Bearer nokey'   https://<IP-address>:<port>/api/ccu/online
 
I’ve found, how to get data from this server, using libcurl calls. But I need additionally to POST some data to this server using JSON-format.
Using console request:
 
curl -k -X POST -d ‘{«1»:0}’ -H ‘Content-type: application/json’ -H ‘Authorization: Bearer nokey’ https://<host>:Port/api/ccu/outputs
 
I can change some output registers of the device, via this server. Is it possible anyhow using some options of libcurl to POST data to this device in JSON-format, like it is done in the previous curl console command? 
 
Thanks in advance!
--
Vladislav Korobov
--
Владислав Коробов
Отправлено из Почты  Mail

-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2025-06-18