0

Outlook アカウントでメールに返信しようとしています。しかし、返信を作成しようとすると (まだ送信しないでください)、次の例外が発生します。

ServiceException: コード: RequestBroker--ParseUri

メッセージ: セグメント 'microsoft.graph.createReply' のリソースが見つかりません。

明らかに、問題は URL にありますが、返信を作成する前にメッセージを取得しようとすると、そのメッセージの返信を作成しようとする場合を除いてすべてが機能するため、意味がありません。

これはコードです:

ConfidentialClientApplication cca = new ConfidentialClientApplication(
    [client_id], [redirect_uri],
    new ClientCredential([secret]),
    new TokenCache(), null);

string[] scopes = new string[]
{
    "email",
    "https://outlook.office.com/mail.read",
    "https://outlook.office.com/mail.read.shared",
    "https://outlook.office.com/mail.readwrite",
    "https://outlook.office.com/mail.readwrite.shared",
    "https://outlook.office.com/mail.send",
    "https://outlook.office.com/mail.send.shared"
};

AuthenticationResult result = (cca as IByRefreshToken).AcquireTokenByRefreshTokenAsync(scopes, [refresh_token]).Result;

GraphServiceClient client = new GraphServiceClient(new DelegateAuthenticationProvider((requestMessage) =>
{
    requestMessage.Headers.Authorization = new
    AuthenticationHeaderValue("Bearer", result.AccessToken);
    return Task.FromResult(0);
}));

string id = [message_id];
Message details = client
    .Me
    .Messages[id]
    .Request()
    .GetAsync()
    .Result; // JUST FOR TESTING, THIS WORKS!
Message reply = client
    .Me
    .Messages[id]
    .CreateReply()
    .Request()
    .PostAsync().Result; // THIS FAILS!!!

reply.Body.ContentType = BodyType.Html;
reply.Body.Content = [html_code];

client
    .Me
    .Messages[reply.Id]
    .Request()
    .UpdateAsync(reply); // HOPE THIS WORKS

client
    .Me
    .Messages[reply.Id]
    .Send()
    .Request()
    .PostAsync()
    .Wait(); // HOPE THIS WORKS TOO

私は .NET 4.7.2、Microsoft.Graph 1.17、および Microsoft.Identity.Client v3.0.2-preview を使用しています (これは、安定したものを使用しようとすると、リフレッシュトークン)

4

2 に答える 2