OUTLOOK REST API使用Node.js

时间:2015-12-17 11:59:59

标签: node.js outlook-restapi office365-restapi

我正在尝试拒绝使用 Outlook REST API 创建的活动。我有这个的身份  创建的事件。我的请求包括Node.js代码:

var body =JSON.stringify(
    {
        "Comment": "Sorry, maybe next time!",
        "SendResponse": "true"
    });
    var options1 = {
                host : 'outlook.office365.com',
                port : 443,
                method : 'POST',
                headers : {
                        'Authorization' : 'Bearer' + token,
                        'Content-Type': 'application/json',
        'Content-Length': Buffer.byteLength(body)   
            },
            json : body,
            path : '/api/v2.0/me/events/EVENT_ID_RECEIVED/decline'   
                }
     };
var str=""; 
     var apiCall=https.request(options1,function(response){

        response.on('data',function(chunk){
            str += chunk;
        });
        response.on('end' , function(){
            console.log("data received is : "+response.data);
            console.log("value is : "+str);
        });
        response.on('error', function(e) {
                      console.log("error received : "+e.message);
               });

    });
    apiCall.write(body);
    apiCall.end();

我已检查过该事件是否存在,但仍然出现此错误。

示例请求

POST //api/v2.0/me/events/GeneratedEventIdWhileCreatingCalender/decline HTTP/1.1
Host: outlook.office365.com    
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 9c925f4a-58df-4409-ca51-278590cfddd1    
{"Comment":"Sorry,maybe next time!","SendResponse":"true"}

示例回复标题

Access-Control-Allow-Origin → *
Access-Control-Max-Age → 86400
Cache-Control → private
Content-Type → application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Date → Fri, 18 Dec 2015 05:02:29 GMT
OData-Version → 4.0
Server → Microsoft-IIS/8.0
Transfer-Encoding → chunked
X-AspNet-Version → 4.0.30319
X-BEServer → HK2PR0301MB1154
X-BackEndHttpStatus → 404
X-CalculatedBETarget → HK2PR0301MB1154.apcprd03.prod.outlook.com
X-DiagInfo → HK2PR0301MB1154
X-Powered-By → ASP.NET
request-id → 6ab4e13e-f8bd-45c8-a80a-c31f8c580141

示例回复正文

{
  "error": {
    "code": "ErrorItemNotFound",
    "message": "The specified object was not found in the store."
  }
}

1 个答案:

答案 0 :(得分:2)

有一个名为iCalUid的属性对于组织者和与会者邮箱中的事件是相同的。但是,它似乎还不支持使用此属性的$ filter。我们将考虑添加这个。与此同时,如果您了解事件的其他详细信息(如开始时间和结束时间),则可以在该时间范围内询问所有事件,并通过比较组织者邮箱中事件的iCalUid属性来确认您正在拒绝正确的事件。 iCalUid在与会者邮箱中的事件属性。