1

I want to make post http request using AndroidAsync library but i can't change the content-type to 'application/x-www-form-urlencoded' for request

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);
}
});

I don't know what to do.

Rami
  • 7,879
  • 12
  • 36
  • 66
Ali Omari
  • 371
  • 3
  • 11
  • *i can't change the content-type to 'application/x-www-form-urlencoded'* looking at your code snippet, I can see that you actually did. What exactly is the problem? – Tim Aug 26 '15 at 08:09
  • the problem that it doesn't work for me, i can't make the http request it stills make the http request using another Content-Type – Ali Omari Aug 30 '15 at 09:24

0 Answers0