问题
I am using Graph SDK in C# to read mail messages and I am able to do that. I want Mime Content of my mail message. How do we pass $value in my request using SDK.
Sample code:
mails = await graphserviceclient
.Me
.Messages
.Request()
.Top(2)
.GetAsync();
Please let me know how we can pass $value in C# code which uses graphserviceclient.
回答1:
We are waiting for some metadata updates to make this easier in the SDK. For the moment, the workaround for getting the MIME content looks something like this:
GraphServiceClient graphClient = new
GraphServiceClient("https://graph.microsoft.com/beta/",authProvider);
var messageId = "...";
var request = graphClient.Me.Messages[messageId].Request()
.GetHttpRequestMessage();
request.RequestUri = new Uri(request.RequestUri.OriginalString +"/$value");
var response = await graphClient.HttpProvider.SendAsync(request);
var message = await response.Content.ReadAsStringAsync();
In the near future you should be able to do:
var aStream = await graphClient.Me.Messages[messageId].Content.Request().GetAsync();
回答2:
Regardless of the SDK, you cannot request $value
of a collection. The API only allows this on an individual message.
Specifically, in terms of the SDK, this isn't supported. This is still an undocumented preview/feature so you will need to call this endpoint directly rather than through the SDK. It's also worth noting that even if it were supported, the SDK still couldn't deserialize the MIME.
来源:https://stackoverflow.com/questions/57825319/how-to-pass-value-in-request-to-get-mime-content-of-mail-using-graph-sdk-not-ap