I'm tryin to use the Dropbox API for a project and when I create the connection the error 400 spawns in my console.
the code is:
String url = "https://api.dropboxapi.com/2/files/get_metadata";
try {
HttpURLConnection openConnection = (HttpURLConnection) new URL(url).openConnection();
//if(url.contains(" "))
//url = url.replace(" ", "%20");
openConnection.setRequestMethod("POST");
openConnection.setRequestProperty("Authorization",
"Bearer <REDACTED>");
openConnection.setRequestProperty("Content-Type", "application/json");
openConnection.setRequestProperty("Accept", "application/json");
openConnection.setDoOutput(true);
String jsonBody = "{\r\n" + " \"path\": \"\",\r\n" + " \"recursive\": true,\r\n"
+ " \"include_media_info\": true,\r\n" + " \"include_deleted\": false,\r\n"
+ " \"include_has_explicit_shared_members\": false,\r\n"
+ " \"include_mounted_folders\": true,\r\n" + " \"include_non_downloadable_files\": true\r\n"
+ "}";
try (OutputStream os = openConnection.getOutputStream()) {
byte[] input = jsonBody.getBytes("utf-8");
os.write(input, 0, input.length);
}
I searched on old topics the solution to add the IF cycle to replace the space inside the url but didnt work. So any advice ??