简体   繁体   中英

Create Recurring Outlook Calendar Event using Node.js

I am trying to create Recurring event using Outlook Rest API in node.js for that I gone through documents whcihis provided by Microsoft but there is no sample example found ,but I am getting error as

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

My Code:

 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){


});

Can some one help me resolve it?

Thanks in Adavnce.

Thank god,I solved my problem.Because of Date format I was not able to create Event.

Working Code:

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"
            }
        }
    };

Thank you All.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM