I am porting an app from BB10 to android. For an http request I am using AQuery.
In Qt on BB10, I can simply post data:
QByteArray data = "test";
QNetworkRequest request;
request.setUrl(new QUrl("example.com"));
QNetworkAccessManager manager = new QNetworkAccessManager(this);
manager->post(request,data);
but in AQuery I can only find a POST method with key/value pairs (from the doc):
String url = "http://search.twitter.com/search.json";
Map<String, Object> params = new HashMap<String, Object>();
params.put("q", "androidquery");
aq.ajax(url, params, JSONObject.class, new AjaxCallback<JSONObject>() {
@Override
public void callback(String url, JSONObject json, AjaxStatus status) {
showResult(json);
}
});
Is there a way to POST just data in AQuery?
I have found out how to do this.
In the AQuery source, in the httpEntity method of the AbstractAjaxCallback class:
HttpEntity entity = null;
Object value = params.get(AQuery.POST_ENTITY);
if(value instanceof HttpEntity){
entity = (HttpEntity) value;
} else {
//urlencoded POST data
}
So all I needed to do was this:
HttpEntity entity = new StringEntity(data);
cb.param(AQuery.POST_ENTITY,entity);
where cb
is my AjaxCallback object.