2016-03-14 2 views
2

Я пытаюсь создать повторяющееся событие, используя Outlook Rest API в node.js, потому что я прошел через документы, предоставленные Microsoft, но образец примера не найден, но я получаю ошибку вСоздать повторяющееся событие календаря Outlook, используя Node.js

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


}); 

Может кто-нибудь помочь мне решить это?

Спасибо, Adavnce.

+0

Попробуйте ввести числовое значение для свойства 'Type' в' Pattern' и 'Range'. Вот документация: https://msdn.microsoft.com/office/office365/api/complex-types-for-mail-contacts-calendar#RecurrencePattern –

+0

Да, я попытался изменить ["Тип": "Ежедневно" как " Введите «: 0 и« Тип »:« NoEnd »в качестве« Тип »: 1], а затем получите тот же номер. –

+0

Что такое «результат»? –

ответ

2

Слава богу, я решил свою проблему. Из-за формата даты мне не удалось создать событие.

Рабочий код:

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

Спасибо все.

Смежные вопросы