Я пытаюсь вызвать веб-API, используя spring-boot и webclient.веб-API имеет граф QL.поэтому я передаю параметры с помощью JsonObject следующим образом.
JSONObject variables = new JSONObject();
JSONObject docParam = new JSONObject();
try {
docParam.put("id", 0);
docParam.put("name", metadata.get("resourceName"));
docParam.put("type", metadata.get("Content-Type"));
docParam.put("datasourceId", 5);
variables.put("document", docParam);
} catch (Exception e) {
}
LinkedMultiValueMap<String, Object> formData = new LinkedMultiValueMap<String, Object>();
formData.add("query", "mutation ($document: Document, $projectId: Int!) { addDocument { id } }");
formData.add("variables", variables);
WebClient webClient = WebClient.builder().baseUrl("https://localhost:44375/api/graph")
.clientConnector(new ReactorClientHttpConnector(httpClient)).build();
webClient.post().contentType(MediaType.APPLICATION_JSON_UTF8).syncBody(formData).retrieve()
.bodyToMono(String.class).subscribe(response -> {
Extract.saveProcessedFile(response);
});
При отправке вызова веб-клиента я получаю следующую ошибку.
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.json.JSONObject and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.springframework.util.LinkedMultiValueMap["variables"]->java.util.LinkedList[0])