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

标签 javascript node.js api outlook calendar

我正在尝试使用 Node.js 中的 Outlook Rest API 创建重复事件,因为我浏览了 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"
            }
        }
    };

谢谢大家。

关于javascript - 使用 Node.js 创建定期 Outlook 日历事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35984305/

相关文章:

javascript - AngularJS:禁用页面/ Controller 加载上的数据绑定(bind),并稍后启用它

javascript - 不明白为什么需要return语句

javascript - 如何在外部javascript文件中使用EL

node.js - 如何在 Jest 测试中发送 Node 命令行参数

api - 在 youtube-api 中下载自己的视频

javascript - NodeJS 是否为每个请求创建一个新线程?

node.js - Access-Control-Allow-Headers 不允许请求 header 字段进行身份验证

windows - 如何更改 node.js 中的默认目录? ( Windows )

azure - Api Post 方法在.net core azure 生产中不起作用

php - 如何使用 PHP 为 Aliexpress API 生成 _aop_signature?