Skip to content

Commit

Permalink
traffic-provbz: add logging for failed request
Browse files Browse the repository at this point in the history
  • Loading branch information
clezag committed Dec 18, 2024
1 parent 353e38b commit 5537433
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,19 @@ public AggregatedDataDto[] getAggregatedDataOnStations(String stationId, String
payload.put("IdPostazioni", stationIdArray);
payload.put("InizioPeriodo", startPeriod);
payload.put("FinePeriodo", endPeriod);
StringEntity stringEntity = new StringEntity(String.valueOf(payload),
String payloadString = payload.toJSONString();
StringEntity stringEntity = new StringEntity(payloadString,
ContentType.APPLICATION_JSON);
HttpPost request = new HttpPost(aggregatedDataOnStationsUrl);
request.setEntity(stringEntity);
HttpEntity entity = client.execute(request).getEntity();
String responseString = EntityUtils.toString(entity, RESPONSE_CHARSET);
return objectMapper.readValue(responseString, AggregatedDataDto[].class);
try {
HttpEntity entity = client.execute(request).getEntity();
String responseString = EntityUtils.toString(entity, RESPONSE_CHARSET);
return objectMapper.readValue(responseString, AggregatedDataDto[].class);
} catch (Exception e) {
LOG.error("Dumping request object: " + payloadString);
throw e;
}
}

/**
Expand Down

0 comments on commit 5537433

Please sign in to comment.