Davidt
Davidt

Reputation: 51

EWS SyncFolderItems is giving me exception "An internal server error occurred. The operation failed."

I have a Synchronisation tool which uses EWS Managed API 'SyncFolderItems' to retrieve changed items in a Calendar folder. It has been running fine for 18 months or so but this week two customers both experienced the same issue. (Could be a coincidence). Both are Office 365 customers.

The sync started failing to complete, and on closer analysis, the SyncFolderItems call was failing with error "An internal server error occurred. The operation failed." No further details given in the error.

I reset the sync (ie set the syncstate back to null so it sync everything in the folder again) . It worked fine for several pagination iterations getting 250 items at a time, but them at some point it failed.

I thought maybe there was an item with alot of data. I reduced the page size to 25 and it worked OK for a bit, then failed. I reduced it a page size of 1 and it fails. There are 1250 items in the folder, so I haven't worked out which item it is failing at yet. It seems inconsistent and I wonder if there is a throttle which has been set higher recently?

I think my next step is to see if there is one offending item and delete it, but its hard work out which item it might be.

Does anyone have any suggestions for what might be going wrong?

  icc = service.SyncFolderItems(Connection.SourceID, ps, null, 1,                                                              
                      SyncFolderItemsScope.NormalItems, syncstate);

Upvotes: 0

Views: 1761

Answers (1)

Inbox
Inbox

Reputation: 71

I having the same issue with SyncFolderItems(..).

The problem seems to exist only in public folders? I tested with a public calender folder. If I call SyncFolderItems for the first time with no status, I get no error. But if I have a status and delete one item in the public folder, I get this error on the next call of SyncFolderItems().

        ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2016, TimeZoneInfo.Local);
        service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
        service.Credentials = new WebCredentials("[email protected]", "pwd");

        Folder f1 = Folder.Bind(service, new FolderId("SOMEFOLDERID OF A PUBLIC CALENDAR FOLDER"), BasePropertySet.FirstClassProperties);
        Console.WriteLine(f1.DisplayName);
        String status = "";
        do
        {

            ChangeCollection<ItemChange> changes = service.SyncFolderItems(f1.Id, BasePropertySet.IdOnly, null, 100, SyncFolderItemsScope.NormalItems, status);

            Console.Write(changes.Count+",");

            status = changes.SyncState;

        } while (true);

ServerInfo: {15.01.1101.019} V2017_04_14

Upvotes: 2

Related Questions