Как закодировать файл запроса Json с помощью уверенности в groovy

response = given()
header("Date", dtime).
header("Authorization", auth_header3).
header("Content-MD5", md5).
header("Content-Type", content_type).
body(new File("regcust")).
when().
post("https://"+ipaddress+":"+port+"/v1/clients").
then().
statusCode(201).
extract().
response();

Здесь «regcust» - это файл json. Если я отправляю запрос с телом json, я получаю исключение, например «java.lang.UnsupportedOperationException: внутренняя ошибка: не удается закодировать regcust в JSON».


person Hanumanth    schedule 01.12.2015    source источник


Ответы (1)


// устанавливаем порт по умолчанию для REST-гарантии RestAssured.port = 80;

// set default URI for REST-assured.
// In integration tests, this would most likely point to localhost.
RestAssured.baseURI = "http://api.openweathermap.org"

Данное Заявление для доступа к API.

Given().auth().preemptive().basic(имя пользователя, пароль) .body(ПРЕОБРАЗОВАТЬ ОБЪЕКТ JSON В STRING И КАК PSS ЗДЕСЬ).with().contentType(JSON).when( ).post(ПУТЬ REST API);

person N..    schedule 02.12.2015