1

In the Microsoft Graph REST API beta documentation in section Get chatMessageHostedContent there is the Java example for getting hosted content bytes for an image:

InputStream stream = graphClient
  .chats("19:[email protected]")
  .messages("1615971548136") .hostedContents("aWQ9eF8wLXd1cy1kOS1lNTRmNjM1NWYxYmJkNGQ3ZTNmNGJhZmU4NTI5MTBmNix0eXBlPTEsdXJsPWh0dHBzOi8vdXMtYXBpLmFzbS5za3lwZS5jb20vdjEvb2JqZWN0cy8wLXd1cy1kOS1lNTRmNjM1NWYxYmJkNGQ3ZTNmNGJhZmU4NTI5MTBmNi92aWV3cy9pbWdv")
  .content()
  .buildRequest()
  .get();

... but using the latest tag microsoftgraph/msgraph-beta-sdk-java (0.9.0-20210615.3) this example doesn't work as content method in ChatMessageHostedContentRequestBuilder cannot be resolved.

With that in mind my question is what is official way of downloading hosted content bytes.

Related question with some more details is also present on GitHub.

1 Answer 1

1

It looks like this will be fixed in the future - but for the time being this workaround should do it:

String valueUrl = graphClient
.chats(chatId)
.messages(messageId)
.hostedContents(hostedContentId)
.getRequestUrlWithAdditionalSegment("$value");

InputStream stream = new CustomRequestBuilder<>(valueUrl, graphClient, null, InputStream.class).buildRequest().get();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.