Java koush AndroidSync库内容类型可以';不变
我想使用AndroidSync库发出post http请求,但无法将请求的内容类型更改为Java koush AndroidSync库内容类型可以';不变,java,android,androidasync-koush,Java,Android,Androidasync Koush,我想使用AndroidSync库发出post http请求,但无法将请求的内容类型更改为'application/x-www-form-urlencoded' AsyncHttpPost post = new AsyncHttpPost(LOGIN_URL); MultipartFormDataBody body = new MultipartFormDataBody(); body.addStringPart("grant-type", "password"); body.addStringP
'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);
}
});
我不知道该怎么办。我无法将内容类型更改为“application/x-www-form-urlencoded”。查看您的代码片段,我可以看出您确实这样做了。问题到底是什么?问题是它对我不起作用,我无法发出http请求,它仍然使用另一种内容类型发出http请求。我无法将内容类型更改为“application/x-www-form-urlencoded”。查看您的代码片段,我可以看出您确实这样做了。到底是什么问题?问题是它对我不起作用,我不能发出http请求,它仍然使用另一种内容类型发出http请求