HTTP 413 for Remote Event Receivers

Today I encountered a very upsetting and unexpected error using SharePoint 2013 on premise Remote Event Receivers.

I’ve configured a local WCF service to handle the events and that worked rather well for the first few versions. But after enough updates, some items didn’t trigger any events anymore. Strange 🙂

So I fired up good old UlsViewer and found out that:

Calling remote event receiver failed. URL = [https://***/Services/RemoteEventReceiver.svc], App Identifier = [], Event Type = [ItemUpdated], Exception = [The remote server returned an unexpected response: (413) Request Entity Too Large.]

The HTTP status code 413 indeed signals a Request Entity Too Large. So I was starting to think that it had nothing to do with SharePoint. I looked through the IIS Failed Request Logs and found that my service was indeed throwing a 413 message.

The reason behind this is that WCF by default only accepts messages up to 65536 bytes (

How to fix this? Just set the maxReceivedMessageSize to a larger value:

<!--Used by SharePoint Add-in-->
<binding name="secureBinding" maxReceivedMessageSize="1000000000">
<security mode="Transport" />

This however doesn’t explain yet why the message size increases gradually for items being updated many times.

What I’ve also found is that inside the message, there are several expected properties of the SPRemoteEventProperties object like BeforeProperties, AfterProperties that contain way more information than you’d expect. One such key in those dictionaries is “snapshots”. This is a SnapshotCollection XML string that contains all changes of all fields up until now. You can imagine how this grows…

As I didn’t find much documentation on this, I’ll just post the basic structure of this object here for future reference

SnapshotCollection [NextSnapshotNumber, NextInternalId]
  Item [Id, Guid, Url, LinkToDoc]
   Comments +Value
    Field [Id] +Value
    SnapshotItem [Id, Version]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s