Я пытаюсь вызвать некоторые API отдыха (которые принимают строку JSON) из клиентской Java-программы, однако я получаю Error 500: javax.servlet.ServletException: java.lang.NoSuchMethodError: com/fasterxml/jackson/databind/ObjectReader.forType(Lcom/fasterxml/jackson/databind/JavaType;)Lcom/fasterxml/jackson/databind/ObjectReader;
или Error 500: javax.servlet.ServletException: java.lang.Exception: See nested Throwable
IЯ могу правильно вызывать Rest API из Почтальона, но Java-программа не работает: Client.java
URL url = new URL(_strUri + "/query/properties");
SendRequest client = new SendRequest(url);
QueryRequest request = new QueryRequest();
if (_auth != null)
{
// do steps to setup a user in the request
}
QueryParameters queryParms = new QueryParameters();
queryParms.setSelectQuery(queryStatement);
request.setQueryParameters(queryParms);
ParentQueryRequest pqr = new ParentQueryRequest();
pqr.setJsonIn(request);
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
JSONUtil.toJSON(pqr, bytesOut);
String jsonString = new String(bytesOut.toByteArray(), "UTF-8");
byte[] response = client.send(jsonString);
httpCode = client.getLastStatus();
String strResponse = new String(response, "UTF-8");
SendRequest.java
public byte[] send(String jsonIn) throws ResponseException,IOException {
HttpURLConnection httpConnection = (HttpURLConnection) _url.openConnection();
httpConnection.setDoOutput(true);
//httpConnection.setRequestMethod("POST");
httpConnection.setRequestProperty("Content-Type", "application/json");
OutputStreamWriter wr = new OutputStreamWriter(httpConnection.getOutputStream());
wr.write(jsonIn);
wr.flush();
InputStream is = httpConnection.getInputStream();
ByteArrayOutputStream out = new ByteArrayOutputStream();
BufferedInputStream buffIn = new BufferedInputStream(is);
BufferedOutputStream buffOut = new BufferedOutputStream(out);
while (true) {
int iByte = buffIn.read();
if (iByte == -1) {
break;
}
buffOut.write(iByte);
}
wr.close();
buffOut.close();
out.close();
is.close();
return out.toByteArray();
}`
Строка JSON, которая должна бытьпрошло - jsonIn:{"queryParameters":{"serverDef":"nRepo","selectQuery":"select * from BayStreet"}}
Любая помощь или руководство приветствуется.