调用图API端点
POST https://graph.microsoft.com/v1.0/me/events
结果是一个400 Bad Request
,响应如下:
{
"error": {
"code":"UnableToDeserializePostBody",
"message":"were unable to deserialize..."
}
}
这是我的密码:
$token = GraphHelper::getUserToken();
GraphHelper::$userClient->setAccessToken($token);
$CreateMeetingBody =
array(
'message' => array (
'subject' => 'Test afspraak Marloes',
'body' => array (
'content' => 'Does morning work for you?',
'contentType' => 'HTML'
),
'start' => array (
'dateTime' => '2022-07-17T18:00:00',
'timeZone' => 'Europe/Paris'
),
'end' => array (
'dateTime' => '2022-07-17T19:00:00',
'timeZone' => 'Europe/Paris'
),
'location' => array (
'displayName' => 'Microsoft Teams',
),
'attendees' => array (
array (
'emailAddress' => array (
'address' => 'stijnd0413@icloud.com',
'name' => 'Stijn Deckers'
),
'type' => 'required'
)
),
'allowNewTimeProposals' => false,
'isOnlineMeeting' => true,
)
);
$headers = [
'Content-Type' => 'application/json',
];
header('Content-Type: application/json; charset=utf-8');
$CreateMeetingJSON = json_encode($CreateMeetingBody);
GraphHelper::$userClient->createRequest('POST', '/me/events')
->attachBody($CreateMeetingJSON)
->addHeaders(['Content-Type' => 'application/json',])
->execute();
“”“
其余的代码可以工作,我可以验证。
发布于 2022-07-14 10:59:19
从message
对象中删除$CreateMeetingBody
对象,并仅保留其内容。
$CreateMeetingBody =
array(
'subject' => 'Test afspraak Marloes',
'body' => array (
'content' => 'Does morning work for you?',
'contentType' => 'HTML'
),
'start' => array (
'dateTime' => '2022-07-17T18:00:00',
'timeZone' => 'Europe/Paris'
),
'end' => array (
'dateTime' => '2022-07-17T19:00:00',
'timeZone' => 'Europe/Paris'
),
'location' => array (
'displayName' => 'Microsoft Teams',
),
'attendees' => array (
array (
'emailAddress' => array (
'address' => 'stijnd0413@icloud.com',
'name' => 'Stijn Deckers'
),
'type' => 'required'
)
),
'allowNewTimeProposals' => false,
'isOnlineMeeting' => true
);
现在json_encode($CreateMeetingBody)
将生成正确的json体。
{
"subject": "Test afspraak Marloes",
"body": {
"content": "Does morning work for you?",
"contentType": "HTML"
},
"start": {
"dateTime": "2022-07-17T18:00:00",
"timeZone": "Europe/Paris"
},
"end": {
"dateTime": "2022-07-17T19:00:00",
"timeZone": "Europe/Paris"
},
"location": {
"displayName": "Microsoft Teams"
},
"attendees": [
{
"emailAddress": {
"address": "stijnd0413@icloud.com",
"name": "Stijn Deckers"
},
"type": "required"
}
],
"allowNewTimeProposals": false,
"isOnlineMeeting": true
}
https://stackoverflow.com/questions/72979298
复制相似问题