Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #include <curl/curl.h>
  2.  
  3. int main (int argc, char *argv[]) {
  4. CURL *hnd = curl_easy_init();
  5.  
  6. curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
  7. curl_easy_setopt(hnd, CURLOPT_URL, "http://localhost:4500/api/SensorData/Add");
  8.  
  9. struct curl_slist *headers = NULL;
  10. headers = curl_slist_append(headers, "cache-control: no-cache");
  11. headers = curl_slist_append(headers, "Connection: keep-alive");
  12. headers = curl_slist_append(headers, "Content-Length: 40");
  13. headers = curl_slist_append(headers, "Accept-Encoding: gzip, deflate");
  14. headers = curl_slist_append(headers, "Host: localhost:4500");
  15. headers = curl_slist_append(headers, "Postman-Token: 08662cd5-bb7e-43eb-9be8-7c319b4d4583,9f4f5db1-4403-4489-9180-b8e7fce9e4cc");
  16. headers = curl_slist_append(headers, "Cache-Control: no-cache");
  17. headers = curl_slist_append(headers, "Accept: */*");
  18. headers = curl_slist_append(headers, "User-Agent: PostmanRuntime/7.17.1");
  19. headers = curl_slist_append(headers, "Content-Type: application/json");
  20. curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
  21.  
  22. curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"id\": \"string\",\n \"humidity\": 66.1\n}");
  23.  
  24. CURLcode ret = curl_easy_perform(hnd);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement