Доброго времени суток!
Кому-нибудь приходилось работает со следующим клиентом на Java?
https://github.com/Afrozaar/wp-api-v2-client-java
Если вкратце, то пытаюсь публиковать статьи из Spring, используя WP REST API.
Вот, простой код для тестирования:
public class WpTest {
public static void main(String[] args) {
String baseUrl = "http://example.com";
String username = "customUser";
String password = "customPassword";
boolean usePermalinkEndpoint = false;
boolean debug = true;
final Wordpress client = ClientFactory.fromConfig(ClientConfig.of(baseUrl, username, password, usePermalinkEndpoint, debug));
String expectedTitle = "Demo Title";
String expectedExcerpt = "Demo Excerpt";
String expectedContent = "Demo Content";
final Post post = PostBuilder.aPost()
.withTitle(TitleBuilder.aTitle().withRendered(expectedTitle).build())
.build();
try {
final Post createdPost = client.createPost(post, PostStatus.publish);
} catch (PostCreateException e) {
e.printStackTrace();
}
}
}
В результате вижу исключение:
Exception in thread "main" java.lang.RuntimeException: Can not create ParsedRestException.
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input at [Source: (byte[])""; line: 1, column: 0]
Где моя ошибка?
Версия библиотеки
4.8.3 Версия ВП
4.9.8
Gradle -
implementation group: 'com.afrozaar.wordpress', name: 'wp-api-v2-client-java', version: '4.8.3'
Полный лог:
полный логException in thread "main" java.lang.RuntimeException: Can not create ParsedRestException.
at com.afrozaar.wordpress.wpapi.v2.exception.ParsedRestException.of(ParsedRestException.java:105)
at com.afrozaar.wordpress.wpapi.v2.exception.PostCreateException.<init>(PostCreateException.java:8)
at com.afrozaar.wordpress.wpapi.v2.Client.createPost(Client.java:181)
at com.afrozaar.wordpress.wpapi.v2.Client.createPost(Client.java:187)
at info.md7.wpat.backend.wpRest.WpTest.main(WpTest.java:39)
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
at [Source: (byte[])""; line: 1, column: 0]
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4145)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4000)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3091)
at com.afrozaar.wordpress.wpapi.v2.exception.ParsedRestException.of(ParsedRestException.java:98)
... 4 more
P.S. Проверяю на чистой установленной ВП и без плагинов с дефолтной темой...