0

我有这个代码

public static String methodPost(final String url, final String dataToPost) throws ClientProtocolException,
        IOException, IllegalStateException, Exception {
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);

        StringEntity se = new StringEntity(dataToPost);
        se.setContentEncoding("UTF-8");
        se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
        httpPost.setEntity(se);

        HttpResponse httpResponse = httpClient.execute(httpPost);
        HttpEntity httpEntity = httpResponse.getEntity();
        return streamToString(httpEntity.getContent());
    }

我在 IPHONE 上发布了这个并且完美地工作:

@"{\"var1\":\"Value1\"}{\"var2\":[{\"item1\":\"1\"},{\"item1\":\"Value2\"}]}"

当我也在 ANDROID 中发帖时。

Response return HTTP 1 400

例子:

methodPost(url, "{\"var1\":\"Value1\"}{\"var2\":[{\"item1\":\"1\"},{\"item1\":\"Value2\"}]}");

但是,我发布这个

methodPost(url, "{\"var1\":\"Value1\"}{\"var2\":\"Value2\"}");

只有当我使用“[]”我有一些错误时,这才能完美地工作

对不起我的英语不好 :)

4

0 回答 0