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

前端 未结 9 824
广开言路
广开言路 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:30

    You can add the JSON string as an InputStream of some kind - I've used the ByteArrayStream, then passing it to the RequestParams you should set the correctMimeType

    InputStream stream = new ByteArrayInputStream(jsonParams.toString().getBytes(Charset.forName("UTF-8")));
    multiPartEntity.put("model", stream, "parameters", Constants.MIME_TYPE_JSON);
    

提交回复
热议问题