Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <curl/curl.h>
- int main (int argc, char *argv[]) {
- CURL *hnd = curl_easy_init();
- curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
- curl_easy_setopt(hnd, CURLOPT_URL, "http://localhost:4500/api/SensorData/Add");
- struct curl_slist *headers = NULL;
- headers = curl_slist_append(headers, "cache-control: no-cache");
- headers = curl_slist_append(headers, "Connection: keep-alive");
- headers = curl_slist_append(headers, "Content-Length: 40");
- headers = curl_slist_append(headers, "Accept-Encoding: gzip, deflate");
- headers = curl_slist_append(headers, "Host: localhost:4500");
- headers = curl_slist_append(headers, "Postman-Token: 08662cd5-bb7e-43eb-9be8-7c319b4d4583,9f4f5db1-4403-4489-9180-b8e7fce9e4cc");
- headers = curl_slist_append(headers, "Cache-Control: no-cache");
- headers = curl_slist_append(headers, "Accept: */*");
- headers = curl_slist_append(headers, "User-Agent: PostmanRuntime/7.17.1");
- headers = curl_slist_append(headers, "Content-Type: application/json");
- curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
- curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"id\": \"string\",\n \"humidity\": 66.1\n}");
- CURLcode ret = curl_easy_perform(hnd);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement