nmarus / node-ews

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

Attributes with the same name are not processed #114

Closed DontCryOk closed 5 years ago

DontCryOk commented 5 years ago

If your ewsArgs object looks like this, it's not getting processed:

const ewsArgs = {
                    'attributes': {
                        'Traversal': 'Shallow'
                    },
                    'ItemShape': {
                        'BaseShape': 'IdOnly',
                        'AdditionalProperties': [
                            {
                            'FieldURI': {
                                'attributes': {
                                    'FieldURI': "item:Subject",
                                }
                            },
                            'FieldURI': {
                                'attributes': {
                                    'FieldURI': "calendar:Location",
                                }
                            },
                            'FieldURI': {
                                'attributes': {
                                    'FieldURI': "calendar:Start",
                                }
                            },
                        }
                    ]
                    },
                    'CalendarView': {
                        'attributes': {
                            'StartDate': req.query.StartDate,
                            'EndDate': req.query.EndDate
                            // 'StartDate':"2019-09-10T22:00:00.000Z",
                            // 'EndDate':"2019-09-26T22:00:00.000Z"
                        }
                    },
                    'ParentFolderIds': {
                        'FolderId': {
                            'attributes': {
                                'Id': folderId
                            }
                        }
                    }
                }

Since the FieldURI keys have the same name, only the last one is used.

DontCryOk commented 5 years ago

Found the solution: const ewsArgs = { 'attributes': { 'Traversal': 'Shallow' }, 'ItemShape': { 'BaseShape': 'IdOnly', 'AdditionalProperties': { 'FieldURI': [{ 'attributes': { 'FieldURI': "item:Subject", } }, { 'attributes': { 'FieldURI': "calendar:Location", } }, { 'attributes': { 'FieldURI': "calendar:Start", } } ] } }, 'CalendarView': { 'attributes': { 'StartDate': req.query.StartDate, 'EndDate': req.query.EndDate // 'StartDate':"2019-09-10T22:00:00.000Z", // 'EndDate':"2019-09-26T22:00:00.000Z" } }, 'ParentFolderIds': { 'FolderId': { 'attributes': { 'Id': folderId } } } }