'How to save the http response to a curl GET request
My C program performs a GET request using curl and redirecting the output to a file so that later on i can open, parse and use its content inside my code.
snprintf(full_data,sizeof(full_data),
"curl -m 10 -k -X GET \"%s/"
"data/json/get?key=key"
"&fields=%s&separator=,\""
" -H \"Authorization: Bearer %s\""
" > /home/pi/Documents/file.txt",
server,
data_to_get,
authtkn
);
FILE *pf;
pf=popen(full_data,"r");
if (!pf)
return -1;
pclose(pf);
Now, i want to make sure that my request status is OK (200/201 ecc) but i dont know how to get the http responde code (and save it somewhere so that i can use it inside my code)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
