qt api code example

Example 1: qt rest api

QUrl url;
url.setScheme(“http”);
url.setHost(“api.thingspeak.com”);
url.setPath(“/channels/”+CHNum+”/feeds.json”);
url.setQuery(“api_key=”+RDKey+”&results=10”);
request.setUrl(url);
reply=nwManager->get(request);

Example 2: qt rest api

//Prepare querystr similar to above steps
request.setHeader(QNetworkRequest::ContentTypeHeader, “application/x-www-form-urlencoded”);
QByteArray postdata = Qvariant(querystr).toByteArray();
restclient->post(myurl,postdata);

Tags:

Misc Example