Compass API calls with BaaS
I'm trying to get status data out from compass API using BaaS but encounter error while doing so.
private Response getStatusData(RestContext context) { String path = "DATAFABRIC/compass/v2/jobs/?queryExecutor=datalake&records=0"; String query = "SELECT LN_tssoc200.osta, COUNT(*) AS count FROM LN_tssoc200 WHERE LN_tssoc200.compnr = 2405 GROUP BY LN_tssoc200.osta"; try { Builder builder = context.getApiClient().createRequest().path(path).request(); builder.header("accept", "application/json"); Invocation invocation = builder.buildPost(Entity.entity(query, MediaType.TEXT_PLAIN)); Response response = invocation.invoke(); return response; } catch (ApiException e) { throw new BaasHttpException("Error when calling API. ", e); } }
But it gives me this error:
{\"suggestedLocalizedText\":\"Internal ERROR Message 600\\nAn internal error occurred. Contact Infor Support.\\nQuery ID ?queryExecutor=datalake&records=0\\n2024-11-27T13:02:12.392249060Z\",\"messageTime\":\"2024-11-27T13:02:12.392249060Z\",\"messageCategory\":\"Internal\",\"messageType\":\"ERROR\",\"line\":\"null\",\"messageCode\":\"600\",\"position\":\"null\",\"message\":\"An internal error occurred. Contact Infor Support.\",\"queryId\":\"?queryExecutor=datalake&records=0\"}
I've tried the query in Compass, API Gateway Compass API and postman to the compass API so I know the problem is with the Java code but I cant figure out where? Any help with this would be appreciated!
Answers
-
The issue is with the two query parameters in the path variable
String path = "DATAFABRIC/compass/v2/jobs/?queryExecutor=datalake&records=0";
From the API documentation, I noticed that the queryExecutor and records are optional query parameters with defaults. So, you can remove that part from the path variable.
alternatively, you can explicitly assign query parameters to the request like.
String detailUrl = "/DATAFABRIC/compass/v2/jobs/"; String query = "select cntr, count(*) from LN_tcibd001 where compnr=51 GROUP BY cntr"; WebTarget webTarget = context.getApiClient().createRequest(); webTarget.queryParam("queryExecutor", "datalake"); webTarget.queryParam("records", 0); Builder builder = webTarget.path(detailUrl).request(); builder.header("Accept", "application/json"); return builder.buildPost(Entity.entity(query, MediaType.TEXT_PLAIN)).invoke(String.class);
0