1
votes

For Office 365 create draft reply message rest API '/messages/{message_id}/createreply' the required request body parameter is 'comment' as per the Office 365 documentation.

Office 365 create draft reply message

I tried to create a draft reply using 'POST /messages/{message_id}/createreply' API with payload as:

{ "Comment": "Fanny, Randi, would you name the group if the project is approved, please?" }

The API gives following error:

{ "error": { "code": "RequestBodyRead", "message": "The parameter 'Comment' in the request payload is not a valid parameter for the operation 'CreateReply'." } }

Is there anything wrong I'm doing or this is a known issue with Office 365 create draft reply API?

1
Can you try with the Microsoft Graph Explorer. I just tried this myself, and it looked to be working without error. Could you also share your code?Shawn Tabrizi
Here is a screenshot of what I did: imgur.com/a/uvWAkShawn Tabrizi
Yes with Microsoft Graph it works fine. But I'm working on an integration connector which consumes Office 365 rest APIs. So I need to perform this task using Office 365 REST API only.Swapnil G

1 Answers

0
votes

I do not believe there is any issues with the create draft reply API. I was able to test this API call using a Native Client I registered in my tenant (with mail.readwrite scope registered), and a PowerShell script using ADAL which did Authentication and the REST call.

Here is that script:

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

I was able to get a valid response from the API with this code. I am a little hesitant to share my output, I do not really know what is sensitive and what isn't, but I believe the error comes from the way your code is formulating your POST request. Can you share your code?

I hope this helps!