I am using office365 app and referenced from https://msdn.microsoft.com/en-us/office/office365/api/mail-rest-operations#Createandsendmessages and https://dev.outlook.com/RestGettingStarted/Tutorial/php create a function:
function reply_to(){
$comment =array("Comment"=> $_POST['comment']);
$url="https://outlook.office365.com/api/v1.0/me/messages/'".$_POST['messeg_id']."'/reply";
$data=OutlookService::makeApiCall($_SESSION['access_token'],'POST',$url,$comment);
print_r($data);
}
and always getting the same error
Array ( [errorNumber] => 400 [error] => Request returned HTTP error 400 ).
I don't know what I am doing wrong I have checked multiple times.
A couple of problems:
'
around your message ID in the URL.$comment
array before passing it to makeApiCall
like so: $comment = json_encode(array("Comment"=> $_POST['comment']));
If you don't JSON encode, then cURL sends the data a form-encoded, rather than as a JSON entity in the body. The server rejects it with a 400 because it's invalid JSON.