-
Notifications
You must be signed in to change notification settings - Fork 145
Closed
Description
Getting 400 Bad Request with error body : "Property attachments in payload has a value that does not match schema."
Trying to upload the attachment as shown below where message is initialized as
Message message = new Message();
and filled other message values like subject, body etc. It is working fine without attachment upload.
final BaseAttachmentCollectionResponse response = new BaseAttachmentCollectionResponse();
try {
response.value = Arrays.asList(getFileAttachment());
}
catch (Exception e) {
e.printStackTrace();
}
message.attachments = new AttachmentCollectionPage(response, null);
}
private FileAttachment getFileAttachment() throws Exception{
FileAttachment fileAttachment = new FileAttachment();
fileAttachment.name = "document.pdf";
File pdfFile = new File("src/main/resources/document.pdf");
InputStream fileStream = new FileInputStream(pdfFile);
fileAttachment.contentBytes = getByteArray(fileStream);
fileAttachment.oDataType = "#microsoft.graph.fileAttachment";
return fileAttachment;
}
API used to send the email is : https://graph.microsoft.com/v1.0/me/sendMail
I am not sure where I am doing wrong.
Appreciate your help here..