ApacheHttpClientを使用してRESTfulJSONPOSTリクエストを送信しています(サードパーティのAPIに)
JSON本文をURLエンコードする必要がありますか?
また、コンテンツ内の何かがすでにURLエンコードされている場合(たとえば、URLエンコードされた文字とのリンクを含むHTMLを送信する場合、たとえば@ 22)、デコードせずに反対側のコンテンツをそのまま取得することを期待する必要がありますか?
たとえば、私がこのようなことをしている場合
String html = "<a href='http://example.com?charOfTheDay=%22'>click me</a>";
// Build the JSON object
JSONObject jsonObj = new JSONObject();
jsonObj.put("html", html);
jsonObj.put("otherKey",otherValue);
//...
// Create the POST object and add the parameters
HttpPost httpPost = new HttpPost(url);
StringEntity entity = new StringEntity(jsonObj.toString(), HTTP.UTF_8);
entity.setContentType("application/json");
httpPost.setEntity(entity);
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(httpPost);
「html」キーの値を取得した後、受信側で同じ値を取得することを期待する必要がありますか?
例:受信側
//after parsing the request string to a JSON object
String html = inputJsonObject.get("html")
// should return "<a href='http://example.com?charOfTheDay=%22'>click me</a>"
送信するものが「現状のまま」受信されるものであることを確認するために必要な他の手順はありますか?