Microsoft Exchange WebServices FindAppointments now return "Expected an item Id but received a folder Id." for Public Calendars

I have been using the Microsoft Exchange WebServices for a few months without any issues to read the appointments from a Public Calendar in Office 365.

Since Tuesday (August 28), the same code without any modifications (the very same build) is now triggering an "Expected an item Id but received a folder Id." exception. It ran fine on Monday.

I found out that my error is happening on this specific instruction:
FindItemsResults<Appointment> lstAppointments = ((CalendarFolder) objFindFoldersCalendar.Folders[0]).FindAppointments(objCalendarView);

Open in new window

Is somebody is aware of anything changed in Office 365 regarding public folders (I can read regular calendar without issues).

It is mostly the same code found at
LVL 72
Éric MoreauSenior .Net ConsultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

D RichterCommented:
Around the same time this week, we also starting getting this error. Our system is trying to connect to a public contacts folder, not a public calendar folder, but we suspect the problem is the same for all types of public folders. Microsoft has certainly either 1) inadvertently broken something or 2) changed the standards for web service calls all of a sudden. We are using the EWS Managed API version 2.2.

The code samples below are not exact per the naming within our production system, but the variable names have been standardized for simplicity and clarity in this post. Any developer who codes with the EWS Managed API should understand this.

Here is the old code (where the error now occurs):

Folder contactsFolder = Folder.Bind(ExchangeService_input, FolderId_input);
FindItemsResults<Item> contacts = contactsFolder.FindItems(SearchFilter_input, ItemView_input);

The error is happening on either one or the other of the two lines above. It varies, because our system connects to multiple O365 domains, and for some domains the error occurs on the first line (where the folder object binding occurs) and for other domains the error occurs on the second line (where the items are retrieved to the FindItemsResults collection).

We believe the following is a workaround. Instead of the two lines of code above, we now do this:

FolderId fldrId = new FolderId(uniqueid_of_folder_string_here);
FindItemsResults<Item> contacts = ExchangeService.FindItems(fldrId, SearchFilter_input, ViewBase_input);

​Now the code connects to the public contacts folder and retrieves the contacts without the "Expected an item Id but received a folder Id" error. Hope this helps.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Éric MoreauSenior .Net ConsultantAuthor Commented:
I will only be able to test your workaround Tuesday morning. But I will be back for sure!
Éric MoreauSenior .Net ConsultantAuthor Commented:
I finally got it to work by using this code:
FolderId folderId = new FolderId(objFindFoldersCalendar.Folders[0].Id.ToString());
FindItemsResults<Item> lstAppointments = objExchangeService.FindItems(folderId, objCalendarView);

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.