0
votes

I have an outlook microsoft mail account. I have successfully used microsoft 365 API to authenticate to login users. i was able to retrieve MSA logging users details.

Now, I want to update login users info using MSA documentation here. https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/user_update I have set all the permissions on the Apps Application side.

Parameters that I want to updates includes, jobTitle,mobilePhone,officeLocation

when I run the code below am having error

{ "error": { "code": "BadRequest", "message": "Request type is not supported.", "innerError": { "request-id": "9659c539-d7c6-433f-9e9a-9d78a25570b3", "date": "2017-11-30T11:26:57" } } }

below is the code

<?php 
session_start();


echo $acc= $_SESSION['access_token'];


echo '<br>cow<br>';


echo $_SESSION['preferred_username'];

echo    $_SESSION['given_name'];


$data_string = array("jobTitle" => 'eLECTRICAL eNGINEER', "mobilePhone" => "15087561" , "officeLocation" => "Montario"); 
$data = json_encode($data_string); 
//$data = $data_string; 
$curl = curl_init();

curl_setopt_array($curl, array( 
CURLOPT_URL => "https://graph.microsoft.com/v1.0/users/[email protected]", 
CURLOPT_RETURNTRANSFER => true, 
CURLOPT_ENCODING => "", 
CURLOPT_MAXREDIRS => 10, 
CURLOPT_TIMEOUT => 30, 
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, 
CURLOPT_CUSTOMREQUEST => "UPDATE", 
CURLOPT_POSTFIELDS => "$data", 
CURLOPT_HTTPHEADER => array( 
"accept: application/json", 
"authorization: Bearer $acc", 
"content-type: application/json; charset=utf-8" 
), 
));

$response = curl_exec($curl); 
$err = curl_error($curl);

curl_close($curl);



print_r($response);
$json = json_decode($response);

//$res = $json->{'items'};




if ($err) { 
echo "cURL Error #:" . $err; 
} else { 
//echo $response; 
}
?>

I do not know if the problem is from URL in the CURL Request. Please help

1

1 Answers

0
votes

These properties are not available for personal Microsoft Account (MSA) user, they are only available for an Azure Active Directory user.

Several endpoints, methods and properties are simply not applicable to Microsoft Accounts as the underlying services are not applicable. For example, Planner is only available to Office 365 business accounts so calls to that endpoint are not supported when using an MSA.