我在重新发布的代码中得到“java.util.zip.zipexception:未知压缩方法”

qvsjd97n  于 2021-07-09  发布在  Java
关注(0)|答案(2)|浏览(467)

我得到了这个错误“java.util.zip.zipexception:未知的压缩方法”,但是我正在处理这个api。它是否与pom.xml中的依赖项有关?
我在google上搜索了这个问题,刚刚看到它是关于zip文件的,但是正如您所看到的,没有zip编码。
以下是我的代码和pom.xml:

@Test
public void trelloCallTest() {
    String key = "mykey";
    String token = "mytoken";

    Response response = given()
        .spec(new RequestSpecBuilder().setBaseUri("https://api.trello.com/1").build())
        .contentType(ContentType.JSON)
        .log().all()
        .when()
        .queryParams("key", key,
            "token",
            token,
            "name", "myname")
        .post("/boards/");

    String jsonString = response.asString();
    System.out.println(jsonString);

    response.then().statusCode(200);
}

这是我的pom.xml:

<dependencies>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.5.2</version>
    </dependency>
    <dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>rest-assured</artifactId>
        <version>4.3.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json- 
             simple -->
    <dependency>
        <groupId>com.googlecode.json-simple</groupId>
        <artifactId>json-simple</artifactId>
        <version>1.1.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.8.6</version>
    </dependency>
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20210307</version>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.3.0</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-all</artifactId>
        <version>2.4.5</version>
    </dependency>
</dependencies>
0s7z1bwu

0s7z1bwu1#

嗨,我编辑了这些台词,工作如下:

Response response = given().spec(new RequestSpecBuilder().setBaseUri("https://api.trello.com/1").setContentType(ContentType.JSON)
                .build())
                .log().all()
                .when()
                .queryParams("key", key,
                       "token",
                             token,
                             "name", "myname")
                .post("/boards/");
nkkqxpd9

nkkqxpd92#

从你的代码你有 post("/boards/") -我没有发现post请求在你尝试执行的方式中被支持https://developer.atlassian.com/cloud/trello/rest/api-group-boards/ 您面临的问题可能与意外的响应类型有关,例如可能是gzip

相关问题