POSTing JSON/XML using android-async-http (loopj)

前端 未结 9 827
广开言路
广开言路 2020-12-02 07:01

I am using android-async-http and really liking it. I\'ve run into a problem with POSTing data. I have to post data to the API in the following format: -

&l         


        
9条回答
  •  没有蜡笔的小新
    2020-12-02 07:15

    Just make JSONObject and then convert it to String "someData" and simply send with "ByteArrayEntity"

        private static AsyncHttpClient client = new AsyncHttpClient();
        String someData;
        ByteArrayEntity be = new ByteArrayEntity(someData.toString().getBytes());
        client.post(context, url, be, "application/json", responseHandler);
    

    It is working fine for me.

提交回复
热议问题