How to pass $value in request to get mime content of mail using graph sdk not api

别来无恙 提交于 2020-01-25 08:22:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!