I am doing Post request and for that I have to set header content type as application/json for that I am writing the following code:
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "charsets: utf-8");
res = curl_easy_setopt(curl, CURLOPT_HEADER,headers);
but when I compile the program the error is comming as
Accept: */*
Proxy-Connection: Keep-Alive
Content-Length: 22
Content-Type: application/x-www-form-urlencoded
Please help me out to set this Content type as application/json as soon as possible
you must place your headers with...
CURLOPT_HTTPHEADER
...while...
CURLOPT_HEADER
...is meant to include the headers in the output
So your solution could be just replace CURLOPT_HEADER with CURLOPT_HTTPHEADER
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With