nmarus / node-ews

A simple JSON wrapper for the Exchange Web Services (EWS) SOAP API.
MIT License
116 stars 52 forks source link

GetUserAvailability request only returns items for last mailbox in MailboxDataArray #92

Open benedictbihl opened 6 years ago

benedictbihl commented 6 years ago

Since im unable to access the support chat, i am going to try my luck here. I hope this is fine. I am trying to fetch the calendar items of multiple rooms in order to determine which one is free at the given time. However, in the response i get from the server, there is only one CalendarEventArray which contains the items of the last entry in my MailboxDataArray (room2@company.com). Is there anything im missing?

Request:

const ewsArgsAv = {
  'TimeZone': {
    'Bias': '-60',
    'StandardTime': {
      'Bias': '0',
      'Time': '02:00:00',
      'DayOrder': '5',
      'Month': '10',
      'DayOfWeek': 'Sunday',
    },
    'DaylightTime': {
      'Bias': '-60',
      'Time': '02:00:00',
      'DayOrder': '1',
      'Month': '4',
      'DayOfWeek': 'Sunday',
    }
  },
  'MailboxDataArray': {
    'MailboxData': {
      'Email': {
        'Address': 'room1@company.com'
      },
      'AttendeeType': 'Room',
      'ExcludeConflicts': 'false'
    },
    'MailboxData': {
      'Email': {
        'Address': 'room2@company.com'
      },
      'AttendeeType': 'Room',
      'ExcludeConflicts': 'false'
    }
  },
  'FreeBusyViewOptions': {
    'TimeWindow': {
      'StartTime': '2018-06-18T00:26:44',
      'EndTime': '2018-06-18T23:26:44'
    },
    'MergedFreeBusyIntervalInMinutes': '60',
    'RequestedView': 'Detailed'
  }
}

Response:

{  
   "FreeBusyResponseArray":{  
      "FreeBusyResponse":{  
         "ResponseMessage":{  
            "attributes":{  
               "ResponseClass":"Success"
            },
            "ResponseCode":"NoError"
         },
         "FreeBusyView":{  
            "FreeBusyViewType":"DetailedMerged",
            "MergedFreeBusy":"00000000022222220000000",
            "CalendarEventArray":{  
               "CalendarEvent":[  
                  {  
                     "StartTime":"2018-06-18T09:30:00",
                     "EndTime":"2018-06-18T12:00:00",
                     "BusyType":"Busy",
                     "CalendarEventDetails":{  
                        "ID":"00000000F64E448C1D682F46B381613F00369AD50700CEF39665EF7BC746BBD2D1EEFFF1B51A0038774FA144000019FD60B3AE971C47B3E1CFD98C307CA100037C3360350000",
                        "Subject":"Meeting 1",
                        "Location":"Room 2",
                        "IsMeeting":"true",
                        "IsRecurring":"false",
                        "IsException":"false",
                        "IsReminderSet":"false",
                        "IsPrivate":"false"
                     }
                  },
                  {  
                     "StartTime":"2018-06-18T13:00:00",
                     "EndTime":"2018-06-18T14:00:00",
                     "BusyType":"Busy",
                     "CalendarEventDetails":{  
                        "ID":"00000000F64E448C1D682F46B381613F00369AD50700CEF39665EF7BC746BBD2D1EEFFF1B51A0038774FA144000019FD60B3AE971C47B3E1CFD98C307CA100037C3360430000",
                        "Subject":"Meeting 2",
                        "Location":"Room 2",
                        "IsMeeting":"true",
                        "IsRecurring":"false",
                        "IsException":"false",
                        "IsReminderSet":"false",
                        "IsPrivate":"false"
                     }
                  },
                  {  
                     "StartTime":"2018-06-18T15:00:00",
                     "EndTime":"2018-06-18T15:30:00",
                     "BusyType":"Busy",
                     "CalendarEventDetails":{  
                        "ID":"00000000F64E448C1D682F46B381613F00369AD50700CEF39665EF7BC746BBD2D1EEFFF1B51A0038774FA144000019FD60B3AE971C47B3E1CFD98C307CA100037C335FFA0000",
                        "Subject":"Meeting 3",
                        "Location":"Room 2",
                        "IsMeeting":"true",
                        "IsRecurring":"true",
                        "IsException":"false",
                        "IsReminderSet":"false",
                        "IsPrivate":"false"
                     }
                  }
               ]
            },
            "WorkingHours":{  
               "TimeZone":{  
                  "Bias":"-60",
                  "StandardTime":{  
                     "Bias":"0",
                     "Time":"03:00:00",
                     "DayOrder":"5",
                     "Month":"10",
                     "DayOfWeek":"Sunday"
                  },
                  "DaylightTime":{  
                     "Bias":"-60",
                     "Time":"02:00:00",
                     "DayOrder":"5",
                     "Month":"3",
                     "DayOfWeek":"Sunday"
                  }
               },
               "WorkingPeriodArray":{  
                  "WorkingPeriod":{  
                     "DayOfWeek":"Monday Tuesday Wednesday Thursday Friday",
                     "StartTimeInMinutes":"480",
                     "EndTimeInMinutes":"1020"
                  }
               }
            }
         }
      }
   }
}
niclego commented 6 years ago

Node ews seems to have this problem all over the place... I get it with find item properties and free busy periods. I'm surprised anybody can use this library without running into errors.

benedictbihl commented 6 years ago

I have since switched to ews-javascript-api since i got no response here. Works well for me and seems to be a better choice for your js-related EWS needs in general.

hansipete commented 3 years ago

Disclaimer: I know this is 2 yrs old, but it might help somebody... so here you go.

It's about the correct way to defined the Array in JSON. In the code you provided, the second 'MailboxData' just overwrote the first. I had success in forming this part like:

'MailboxDataArray': {
    'MailboxData': [
    {
      'Email': {
        'Address': 'room1@company.com'
      },
      'AttendeeType': 'Room',
      'ExcludeConflicts': 'false'
    },
    {
      'Email': {
        'Address': 'room2@company.com'
      },
      'AttendeeType': 'Room',
      'ExcludeConflicts': 'false'
    }]
  },