surya singh surya singh - 1 year ago 153
reST (reStructuredText) Question

Outlook Rest Api -- Get a calendar view (REST) in particular timezone

I'm trying to retrieve a calendar view in particular time zone. According to Docs we need to use the Prefer: outlook.timezone header to specify the time zone. But after setting the prefer header the api is returning 400 error status.

var queryParams = {
'startDateTime' : params.timeMin,
'endDateTime' : params.timeMax,
'$select': 'Start,End'
// header
var headers = {
'Prefer' : 'Asia/Kolkata'
'auth': { 'bearer': token},
headers: headers
}, function(error, response, body) {


Answer Source

You need to change

var headers = {
    'Prefer' : 'Asia/Kolkata'


var headers = {
    'Prefer' : 'outlook.timezone="Asia/Kolkata"'

In case of header 'Prefer' : 'Asia/Kolkata' server responds with invalid Prefer header error.

The valid format for Prefer header is:

Prefer: outlook.timezone="<time zone>"


List of tz database time zones

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download