JSON requests in C using libcurl

前端 未结 7 900
孤独总比滥情好
孤独总比滥情好 2020-12-08 12:04

I\'m defining a PUT request with a JSON request body using libcurl in C.

This how I\'m doing it:

    sprintf(jsonObj, \"\\\"name\\\" : \\\"%s\\\", \\         


        
7条回答
  •  抹茶落季
    2020-12-08 12:40

    The problem may be with the headers. When you are configuring your curl_slist headers I think you should assign the output of curl_slist_append back to headers:

    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, "charset: utf-8");
    

提交回复
热议问题