How to send a JSONObject to a REST service?

前端 未结 3 1809
北海茫月
北海茫月 2021-01-06 13:33

Retrieving data from the REST Server works well, but if I want to post an object it doesn\'t work:

public static void postJSONObject(int store_type, Favorite         


        
3条回答
  •  误落风尘
    2021-01-06 14:14

    Try setting the content type header:

    postMethod.addRequestHeader("Content-Type", "application/json");

    Btw, I strongly recommend Jersey. It has a REST client library which makes these kind of things much easier and more readable

提交回复
热议问题