首页 > 解决方案 > 使用 NodeJS 在 Outlook 中创建日历事件

问题描述

我需要使用 NodeJS 脚本在 Outlook 中创建一个日历事件。我已经搜索了每个地方并尝试了不同的 npm 包,但我没有得到解决方案。

我已经尝试过Node-Outlook NPM 包,但文档不清楚如何创建日历事件。

var outlook = require('node-outlook');

var newEvent = {
    "Subject": "Discuss the Calendar REST API",
    "Body": {
        "ContentType": "HTML",
        "Content": "I think it will meet our requirements!"
    }
};

let createEventParameters = {
    token: ['Access token'],
    event: newEvent,
    user : <user>
};
outlook.calendar.createEvents(createEventParameters, function (error, event) {
    if(error) {
        console.log(error);                 
    } else {
        console.log(event);                         
    }
});

这个 npm 包返回错误:

REST request returned 401; body: {"error":{"code":"InvalidAudience","message":"The audience claim value is invalid 'aud'.

请帮我解决这个问题,如果您知道创建日历事件的任何不同方式,请提出建议。

谢谢

标签: node.jsoutlookoutlook-calendar

解决方案


尝试在 Azure 配置中的 API 权限中设置此权限 Calendars.ReadWrite


推荐阅读