Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Not able to send attachment with this API https://graph.microsoft.com/v1.0/me/sendMail #192

Copy link
Copy link
@poonamsehjwani

Description

@poonamsehjwani
Issue body actions

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..

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.