POST /api/card/{card-id}/query/{export-format}
When make the above api call from Springboot restTemplate getting error response that missing required parameter {{from}}. from is parameter used in my metabse query. i tried a lost but no success. any workaround. but when i use paythin it worked well. will share the entire code.
Map<String, String> creds = new HashMap<>();
creds.put("username",appProperties.getMailAccounts().getFirst().getMetaBase().getUser() );
creds.put("password",appProperties.getMailAccounts().getFirst().getMetaBase().getPass()); // TODO: Add password here
Map<String, Object> response = webClient.getWebClient().post()
.uri("https://in-analytics.***.com/api/session")
.bodyValue(creds)
.retrieve()
.bodyToMono(Map.class)
.block();
this.inAnalyticsSessionId = (String) response.get("id");
{
try {
QueryParamDetails payload = new QueryParamDetails();
payload.setType("date/single");
List<Object> target = new ArrayList<>();
target.add("variable");
List<Object> templteArray = new ArrayList<>();
templteArray.add("template-tag");
templteArray.add("from");
target.add(templteArray);
payload.setTarget(target);
payload.setValue("2025-06-29");
List<QueryParamDetails> allPayload = new ArrayList<>();
allPayload.add(payload);
Map<String,Object> map = new HashMap<>();
map.put("parameters", allPayload);
String jsonBody = objectMapper.writeValueAsString(map);
String response = webClient.getWebClient().post()
.uri("https://in-analytics.***.com/api/card/5881/query/json")
.header("Content-Type", "application/json")
.header("X-Metabase-Session", inAnalyticsSessionId)
.header("Cookie", "metabase.SESSION=" + inAnalyticsSessionId)
.bodyValue(jsonBody)
.retrieve()
.bodyToMono(String.class)
.block();
System.out.println("response: " + response);
} catch (Exception e) {
e.printStackTrace();
}
}