使用Microsoft Graph Client创建日历事件

Jul*_*sta 2 outlook-restapi microsoft-graph

我试图弄清楚如何使用Microsoft Graph JavaScript Client创建日历事件。

我已经设法检索了必要的内容,accessToken并且可以与API进行交互(即检索事件,日历,前10名电子邮件),但是我不确定如何使用API​​创建事件。

    client
      .api('/me/events')
      .header('X-AnchorMailbox', emailAddress)
Run Code Online (Sandbox Code Playgroud)

我是否使用post发送事件json对象?

Mar*_*eur 6

我建议查看Read Medocumentation以获取有关如何使用此库的详细信息。

要回答您的问题,您需要创建一个Event对象。例如:

var event = {
    "subject": "Let's go for lunch",
    "body": {
        "contentType": "HTML",
        "content": "Does late morning work for you?"
    },
    "start": {
        "dateTime": "2017-04-15T12:00:00",
        "timeZone": "Pacific Standard Time"
    },
    "end": {
        "dateTime": "2017-04-15T14:00:00",
        "timeZone": "Pacific Standard Time"
    },
    "location": {
        "displayName": "Harry's Bar"
    },
    "attendees": [{
        "emailAddress": {
            "address": "samanthab@contoso.onmicrosoft.com",
            "name": "Samantha Booth"
        },
        "type": "required"
    }]
}
Run Code Online (Sandbox Code Playgroud)

然后,您需要.post将此对象连接到/events端点:

client
    .api('/me/events')
    .post(event, (err, res) => {
        console.log(res)
    })
Run Code Online (Sandbox Code Playgroud)