使用 Node.js 创建定期 Outlook 日历事件

Create Recurring Outlook Calendar Event using Node.js

本文关键字:Outlook 日历 事件 Node js 创建 使用      更新时间:2023-09-26

我正在尝试在节点中使用Outlook Rest API创建重复事件.js为此我浏览了Microsoft提供的文档,但没有找到示例示例,但是我收到错误

{
    "error": {
        "code": "RequestBodyRead",
         "message": "An unexpected 'PrimitiveValue' node was found when reading from the JSON reader. A 'StartObject' node was expected."
    }
}

我的代码:

 var jsonBody = {
      "Subject": "test event",
        "Body": {
            "ContentType": "HTML",
            "Content": "sadsad"
        },
        "Start": "2016-05-27T00:00:00.000Z",
        "End": "2016-05-27T00:30:00.000Z",
        "Attendees": result,
         "Type":"Occurrence",
        "Recurrence": {
            "Pattern": {
                "DayOfMonth": 0,
                "Month": 0,
                "Type": "Daily",
                "Interval": 3,
                "FirstDayOfWeek": "Sunday"
            },
            "Range": {
                 "StartDate": "2015-05-27T00:00:00Z",
                "EndDate": "0001-01-01T00:00:00Z",
                "NumberOfOccurrences": 0,
                "Type": "NoEnd"
            }
        }
    };
var optionsForCreatingcalendar = {                              
    uri: 'https://outlook.office.com/api/v2.0/me/events',
    port: 443,
    method: 'POST',
    headers: {
    'Authorization': 'Bearer ' + token,
    'Content-Type': 'application/json'
    },
    json: true,
    body: jsonBody,                
    resolveWithFullResponse: true,
    simple: false
};
// --- API call using promise-----
rp(optionsForCreatingcalendar)
.then(function(response) {  
},function(err){

});

有人可以帮我解决吗?

谢谢在阿达文斯。

感谢上帝,我解决了我的问题。由于日期格式,我无法创建事件。

工作规范:

var jsonBody = {
      "Subject": "test event",
        "Body": {
            "ContentType": "HTML",
            "Content": "sadsad"
        },
       "Start": {
                "DateTime": "2016-05-21T10:10:00",
                "TimeZone":"India Standard Time"
                },
        "End": {
                "DateTime":"2016-05-21T11:10:00",
                "TimeZone":"India Standard Time"
        },
        "Attendees": result,
         "Type":"Occurrence",
        "Recurrence": {
            "Pattern": {
                "DayOfMonth": 0,
                "Month": 0,
                "Type": "Daily",
                "Interval": 3,
                "FirstDayOfWeek": "Sunday"
            },
            "Range": {
                 "StartDate": "2016-05-27",
                "EndDate": "2016-06-27",
                "NumberOfOccurrences": 0,
                "Type": "NoEnd"
            }
        }
    };

谢谢大家。