Hello all,
I tried to filter data in cmdbuild class. I wrote this code
URL url = new URL(baseUrl + “/services/rest/v2/classes/” + className + “/cards?filter={“attribute”:”" + keyField + “”,“operator”:“equal”,“value”:"" + keyValue + “”}");
System.out.println(url);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod(“GET”);
// conn.setRequestProperty(“Connection”, “keep-alive”); //roland
conn.setRequestProperty(“Content-Type”, “application/json”);
conn.setRequestProperty(“CMDBuild-Authorization”, sessionToken);
//conn.setRequestProperty(“Accept”,"/");
//conn.setDoInput(true);
//conn.setDoOutput(true);
int responseCode = conn.getResponseCode();
if (responseCode == 200) {
JSONArray records = new JSONObject(readResponse(conn)).getJSONArray(“data”);
return records.length() > 0 ? records.getJSONObject(0) : null;
} else {
output :
http://10.15.2.138:8180/cmdbuild-test/services/rest/v2/classes/test_import/cards?filter={“attribute”:“Code”,“operator”:“equal”,“value”:“server1”}
Erreur : 400
Message d’erreur : {“success”:false,“messages”:[{“level”:“ERROR”,“show_user”:false,“message”:“java.lang.IllegalArgumentException: error deserializing json filter =< {“attribute”:“Code”,“operator”:“equal”,“value”:“server1”} >, caused by: java.lang.IllegalArgumentException: unable to parse illegal attribute filter = “Code” (invalid top-level key, must be one of ‘and’,‘or’,‘simple’,‘not’)”}]}
java.lang.RuntimeException: Erreur lors de la recherche : null
at CMDBuildConnector.findRecord(CMDBuildConnector.java:250)
at Main.main(Main.java:82)
but it does’t work
can you help me please?
roland