Passing a JSON string to HTTP GET method using libcurl -


i want pass json string via http method. server side requires json follows:

const char* json[]= {\"revisions\":[{\"revision\":\"01\"},{\"revision\":\"02\"},{\"revision\":\"03\"},{\"revision\":\"04\"}]} 

so intend pass such json this, i'm not sure whether should convert query string format or not, this:

curl_easy_setopt(curl, curlopt_url, "http://example.com?{\"revisions\"[{\"revision\":\"01\"},{\"revision\":\"02\"},{\"revision\":\"03\"},{\"revision\":\"04\"}]}"); 

i know should use post in case. however, requirement server side requires using get. appreciated.

besides query string, can pass data in http requests via:

  • header:

    struct curl_slist *chunk = null; chunk = curl_slist_append(chunk, "json: {\"revisions\"[{\"revision\":\"01\"},{\"revision\":\"02\"},{\"revision\":\"03\"},{\"revision\":\"04\"}]}"); curl_easy_setopt(curl, curlopt_httpheader, chunk); 
  • cookie:

    curl_easy_setopt(curl, curlopt_cookie, "json={\"revisions\"[{\"revision\":\"01\"},{\"revision\":\"02\"},{\"revision\":\"03\"},{\"revision\":\"04\"}]}"); 

references


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -