UploadDocument APi erroring out

UploadDocument APi erroring out

this is the repsonse iam getting when i invoke from java code

200
{"response": {"uri":"/recruit/private/json/Candidates/uploadDocument","error": {"code":9832,"message":"Invalid parameter value"}}}

code snippet:
byte[] encoded = Base64.getEncoder().encode(Files.readAllBytes(filePath));
String base64Str = new String(encoded, "UTF-8");
        
// Create connection object, based on the given url-name
HttpURLConnection connection = (HttpURLConnection)url.openConnection();

// Properties in order to ensure succesful POST-request
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);

// Specify request-method and headers
connection.setRequestMethod("POST");

Please help its urgent