使用trello api创建板时出错

wljmcqd8  于 2021-07-11  发布在  Java
关注(0)|答案(1)|浏览(369)

使用trello api创建板时出错。
同样尝试同样的 Postman ,它是创造一个董事会与200的地位。文档链接:[https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-董事会职位][1]
请帮助我,让我知道我在哪里犯错。添加了我的代码和输出。

import io.restassured.RestAssured;
import static io.restassured.RestAssured.*;

public class CreateBoard {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        RestAssured.baseURI = "https://api.trello.com";

        given().log().all().queryParam("key", "yourkey")
        .queryParam("token", "yourtoken")
        .queryParam("name", "Automation Board")
        .when().post("/1/boards/")
        .then().log().all().assertThat().statusCode(200);

    }

}

输出:

Error parsing body
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.ReflectionUtils (file:/C:/Users/sharf/Downloads/REST%20ASSURED%20API/json-path-4.3.1-dist/json-path-4.3.1-deps/groovy-3.0.3.jar) to constructor java.lang.AssertionError(java.lang.String)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.ReflectionUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Exception in thread "main" java.lang.AssertionError: 1 expectation failed.
Expected status code <200> but was <415>.

    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:72)
    at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:59)
    at
t3psigkw

t3psigkw1#

我刚刚补充说

.contentType(ContentType.JSON)

而且成功了。任何人请让我知道为什么这工作时,我添加了上述行。因为trello文档中没有提到。

相关问题