使用Google Http Client设置路径部分

时间:2012-11-14 09:54:43

标签: java json http rest httpclient

我正在尝试使用路径变量访问Rest资源以访问不同的资源:

@Test
public void testGetDBs() throws IOException {
    GooUrl url = new GooUrl(GOO_URL + "users/id1"); // This works
    List<String> path = new LinkedList<String>();
    path.add("users");
    path.add("id1");
    //url.setPathParts(path); // this does not work
    HttpRequest request;
    try {
        request = requestFactory.buildGetRequest(url);
        request.setMethod(HttpMethod.POST);
        String result = request.execute().parseAsString();
        System.out.println("Result = " + result);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

然而,我正在

java.net.MalformedURLException: For input string: "8888users"

当我做setPathParts

0 个答案:

没有答案