Getting MIME content is not working in Graph API ( 3.1.0) for Java SDK

Singhal, Abhinav 1 Reputation point
2021-04-12T18:19:46.453+00:00

Hi Support team,
I am trying to get the mime-content of the message with attachment,
I am using 3.1.0, which has content method, I am using this method to get the mime-content(uses /$value), below is my request. Below is the reference docuementation we are using.

https://learn.microsoft.com/en-us/graph/api/attachment-get?view=graph-rest-1.0&tabs=http#example-3-expand-and-get-the-properties-of-the-item-attached-to-a-message

I am getting the response with code 200 and header as Content-Type: text/plain, body has nothing and body.contentLength() is coming as -1,

Kindly help me if I am missing anything in the request/headers

Code for mime content for message:
Request: https://graph.microsoft.com/v1.0/users/{Email Id}/messages/{message id}/$value
graphClient.users({emailId}).messages(message.id).content()
.buildRequest()
.get();
I tried to fetch the same mime-content for attachment as well, below is the code
final String baseUrl = graphClient.users(userProfile).messages(message.id).attachments(attchId).buildRequest().getRequestUrl().toString();
final CustomRequestBuilder downloadRequestBuilder = new CustomRequestBuilder<>(baseUrl + "/$value", graphClient, new ArrayList(), InputStream.class);
final InputStream stream = downloadRequestBuilder.buildRequest().get();

In either case, I am getting the body as empty and body.contentLenght() is -1.
Kindly help me on this.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,249 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.