对于Office 365创建草稿回复邮件rest API '/messages/{message_id}/createreply‘,根据Office 365文档,所需的请求正文参数为'comment’。
Office 365 create draft reply message
我尝试使用'POST /messages/{message_id}/createreply‘API创建一个回复草稿,有效负载如下:
{ "Comment":“范妮,兰迪,如果项目通过,你能说出小组的名字吗?”}
API给出以下错误:
{ "error":{ "code":"RequestBodyRead","message":“请求负载中的参数'Comment‘不是’CreateReply‘操作的有效参数。”}}
我是否做错了什么,或者这是Office 365创建草稿回复API的已知问题?
发布于 2016-11-30 03:29:35
我不认为创建草稿回复API有任何问题。我能够使用我在租户中注册的Native Client (注册了mail.readwrite作用域)和使用ADAL的PowerShell脚本来测试这个API调用。
以下是该脚本:
Add-Type -Path "..\ADAL\Microsoft.IdentityModel.Clients.ActiveDirectory.dll";
$output = ".\Output.txt"
$accessToken = ".\Token.txt"
$clientId = "<AppID>";
$tenantId = "<Tenant or Common>";
$resourceId = "https://outlook.office.com"
$redirectUri = new-object System.Uri("<Reply URL>")
$login = "https://login.microsoftonline.com"
$authContext = New-Object Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext @(("{0}/{1}" -f $login,$tenantId), $false);
$authenticationResult = $authContext.AcquireToken($resourceId,$clientID,$redirectUri);
($token = $authenticationResult.AccessToken) | Out-File $accessToken
$headers = @{
"Authorization" = ("Bearer {0}" -f $token);
"Content-Type" = "application/json";
}
$body = @{
Comment= 'This is my comment'
}
$bodyJSON = $body | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri ("{0}/api/beta/me/messages/<message id>/createreply" -f $resourceId) -Headers $headers -Body $bodyJSON -OutFile $output使用此代码,我能够从API获得有效的响应。我在分享我的输出时有点犹豫,我真的不知道什么是敏感的,什么是不敏感的,但我相信错误来自于你的代码制定你的POST请求的方式。你能分享你的代码吗?
我希望这能帮到你!
https://stackoverflow.com/questions/40846374
复制相似问题