0

I have the next part, which is where I use Microsoft Graph to download an attachment, but I'm at the part where I already get the attachment, but how do I pass that what is returned as an Attachment can be passed to a byte array?

The following is the code used where I obtain the attached files, passing the id of the message and the id of the attached file, and then proceed to download it, but there is a part there that generates an error that is where the method is being used content(), but if I remove it I get an error and I don't know how else I can convert that Attachment to byte[]

Attachment attachment = _userClient.me().messages(listIdMessage.get(i)).attachments(idAttachment)
                        .buildRequest()
                        .get();

byte[] fileBytes = attachment.additionalDataManager().
                    InputStream inputStream = _userClient.me().messages(idMessage).attachments(idAttachment).content().buildRequest().get();
                OutputStream outputStream = new FileOutputStream("path/file/" + attachment.name);
                outputStream.write(fileBytes);
                outputStream.close();

I just want to somehow download an attachment from an email where on this occasion I use Microsft Graph, if anyone knows a way to convert from Attachment to byte[] with the code I proposed or in another way I would appreciate it.

note: I am using Spring boot