我使用 AndroidQuery(AQuery) 库用于 Android 开发,我需要创建一个包含 StringEntity(一些字符串) 的 PUT 请求。
以下是我的代码,请指出问题并提出建议。我已经尝试过不加 ".header("_method", "PUT")" ,但是还是不行。
HttpEntity entity = null;
try {
entity = new StringEntity(stringData, HTTP.UTF_8);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Map<String, Object> params = new HashMap<String, Object>();
params.put(AQuery.POST_ENTITY, entity);
AQuery aq = new AQuery(this);
aq.progress(pDialog).ajax(url, params, String.class, new AjaxCallback<String>() {
@Override
public void callback(String url, String json, AjaxStatus status) {
if(status.getCode() == 200) {
} else {
}
}
}.header("Content-Type", "application/x-www-form-urlencoded")
.header("_method", "PUT"));