I’m using Retrofit library to upload document for a beneficial owner in Sand box enviroment as below:
public void uploadDocumentForBeneficialOwner(String dwollaAccessToken, String beneficialOwnerIdFromDwolla, final Uri imageUri, String documentType) {
File file = new File(RealPathUtil.getRealPath(context, imageUri));
RequestBody documentTypePart = RequestBody.create(documentType, MediaType.parse("text/plain"));
MultipartBody.Part imagePart = MultipartBody.Part.createFormData("file", "Image", RequestBody.create(file, MediaType.parse("image/*")));
HashMap<String, String> headers = new HashMap<>();
headers.put("Authorization","Bearer " + dwollaAccessToken);
headers.put("Content-Type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");
headers.put("Cache-Control","no-cache");
headers.put("Accept", "application/vnd.dwolla.v1.hal+json");
Call<ResponseBody> call = APIService.apiService.uploadDocumentForBeneficialOwners(headers, beneficialOwnerIdFromDwolla, documentTypePart, imagePart);
call.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
if (response.code() == 200 || response.code() == 201) {
String location = response.headers().get("Location");
uploadDocumentCallback.completed(true, location, null);
} else {
//Failure
String message = response.message();
uploadDocumentCallback.completed(false, null, message);
}
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
uploadDocumentCallback.completed(false, null, t.getMessage());
}
});
}
Whenever I call uploadDocumentForBeneficialOwner() function I get code 400 or 500 as image below
How can I upload a document to beneficial owners from Android device?
Thanks,
Vinh