Ошибка при создании платы с использованием Trello API

#java #api #rest #automation #trello

#java #API #rest #автоматизация #trello

Вопрос:

Ошибка при создании платы с использованием Trello API.

Также пробуя то же самое с почтальоном, он создает доску со статусом 200. Ссылка на документацию: [https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-post ][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 ASSURED API/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 
  

Ответ №1:

Я только что добавил

 .contentType(ContentType.JSON)
  

и это сработало.
Кто-нибудь, пожалуйста, дайте мне знать, почему это сработало, когда я добавил приведенную выше строку.
Поскольку это не было упомянуто в документации trello.