- Code: Select all Expand view RUN
- curl --location --request POST "https://sandbox.gerencianet.com.br/v1/authorize" --header "Authorization: Basic Q2..." --header "Content-Type: application/json" --data-raw "{ \"grant_type\":\"client_credentials\"}"
I'm trying to convert a CURL.EXE command to LIBCURL, I have the example below in C.
- Code: Select all Expand view RUN
- CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "https://sandbox.gerencianet.com.br/v1/authorize");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: Basic Q2...");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
const char *data = "{\n \"grant_type\": \"client_credentials\"\n}";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);
But the command curl_slist_append did not find an equivalent in lib using xHarbour.
Can someone help?
Thanks