我想使用AndroidAsync库发布http请求,但我无法将内容类型更改为'application/x-www-form-urlencoded'
以获取请求
AsyncHttpPost post = new AsyncHttpPost(LOGIN_URL);
MultipartFormDataBody body = new MultipartFormDataBody();
body.addStringPart("grant-type", "password");
body.addStringPart("username", userName);
body.addStringPart("password", password);
body.setContentType("application/x-www-form-urlencoded")
post.setBody(body);
AsyncHttpClient.getDefaultInstance().executeJSONObject(url, new AsyncHttpClient.JSONObjectCallback() {
// Callback is invoked with any exceptions/errors, and the result, if available.
@Override
public void onCompleted(Exception e, AsyncHttpResponse response, JSONObject result) {
if (e != null) {
e.printStackTrace();
return;
}
System.out.println("I got a JSONObject: " + result);
}
});
我不知道该怎么做。