如何修复URIBuilder getRequest参数转义

时间:2019-05-10 13:55:56

标签: java apache-httpclient-4.x

在我的代码中,我想在SugarCRM REST API V10上启动GET请求,对于过滤器,我必须在请求中添加一些参数

应为:

https://domain/rest/v10/Accounts?filter=[{"system_uuid_c":"f937456c-fdac-4d90-b1ca-ba31d4eb2922"}]

结果:

https://domain/rest/v10/Accounts?filter%3D=%5B%7B%22system_uuid_c%22%3A%22f937456c-fdac-4d90-b1ca-ba31d4eb2922%22%7D%5D

我的代码:

    filter = filter.concat("[{");
    filter = filter.concat("\"system_uuid_c");
    filter = filter.concat("\":");
    filter = filter.concat("\"");
    filter = filter.concat(system_uuid);
    filter = filter.concat("\"}]");

    URIBuilder builder = new URIBuilder(HOST + PATH);
            builder.addParameter("filter", filter);
            HttpGet httpGet = new HttpGet(builder.build());

"对于过滤器很重要。

1 个答案:

答案 0 :(得分:0)

URL有效。当objectMapper尝试将结果String转换为对象时出现错误。所以一切都很好:)

谢谢您的帮助。