Please help me to implement an HTTP Get request using curl in C.
I need to hit URL with parameters like https://www.googleapis.com/tasks/v1/users?name=pradeep&lastname=singla
I used CURLOPT_HTTPHEADER
to set parameters with Header but without success. I implemented it like
struct curl_slist* contentheader = NULL;
contentheader = curl_slist_append(contentheader, "name=pradeep");
contentheader = curl_slist_append(contentheader, "lastname=singla");
curl_easy_setopt(curl, CURLOPT_URL, "https://www.googleapis.com/tasks/v1/users");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, contentheader);
curl_easy_perform(curl);
In this case an error occured like "no correct APi request". So I thought that I can use
char *charff = "name=pradeep&lastname=singla";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, charfff);
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L); curl_easy_perform(curl);
but the same error is occurring.
Can anyone please help me ? I can put my request for both POST and GET method because server method may change anytime.