I am currently trying to get the list of Jobs from DBT cloud but the response from my java code in incomplete but postman is able to get the complete response.
public static JobsDTO performGETListJobs(int accountId) throws Exception {
JobsDTO jobsDTO = new JobsDTO();
String URI = DEFAULT_DBT_URL + "/" + accountId + "/jobs";
StringBuilder response = new StringBuilder();
try {
URL url = new URL(URI);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Authorization", DEFAULT_AUTH_TOKEN);
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Accept", "application/json");
connection.setDoOutput(true);
try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"))) {
String responseLine = null;
while ((responseLine = br.readLine()) != null) {
response.append(responseLine.trim());
}
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println(response.toString());
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
}
} catch (IOException e) {
e.printStackTrace();
}
String res = response.toString();
System.out.println("response : " + mapper.writerWithDefaultPrettyPrinter().writeValueAsString(res));
jobsDTO = (JobsDTO) toObjectDTO(res, JobsDTO.class);
System.out.println(jobsDTO.getStatus().getIsSuccess());
System.out.println(jobsDTO.getData().size());
System.out.println("Response ready to send");
return jobsDTO;
}
Response from the above code is :
{"status":{"code":200,"is_success":true,"user_message":"Success!","developer_message":""},"data":[],"extra":{"filters":{"limit":100,"offset":0,"account_id":102743},"order_by":"id","pagination":{"count":0,"total_count":0}}}
Response in Postman is :
{ "status": { "code": 200, "is_success": true, "user_message": "Success!", "developer_message": "" }, "data": [ { "execution": { "timeout_seconds": 300 }, "generate_docs": false, "run_generate_sources": false, "id": 126169, "account_id": 102745, "project_id": 156324, "environment_id": 120510, "name": "Manual Run", "dbt_version": null, "created_at": "2022-09-09T09:32:45.997218+00:00", "updated_at": "2022-09-09T09:32:45.997238+00:00", "execute_steps": [ "dbt run", "dbt test" ], "state": 1, "deactivated": false, "run_failure_count": 0, "deferring_job_definition_id": null, "lifecycle_webhooks": false, "lifecycle_webhooks_url": null, "triggers": { "github_webhook": false, "git_provider_webhook": false, "custom_branch_only": false, "schedule": false }, "settings": { "threads": 4, "target_name": "default" }, "schedule": { "cron": "0 * * * *", "date": { "type": "every_day" }, "time": { "type": "every_hour", "interval": 1 } }, "is_deferrable": false, "generate_sources": false, "cron_humanized": "Every hour", "next_run": null, "next_run_humanized": null } ], "extra": { "filters": { "limit": 100, "offset": 0, "account_id": 102745 }, "order_by": "id", "pagination": { "count": 1, "total_count": 1 } } }
Data part is having empty array or the inputstream is not able to get that value.
Please help me with getting the full response using java.