Quantcast
Channel: Developing Apps for SharePoint 2013 forum
Viewing all articles
Browse latest Browse all 8089

Delete a RemoteEventReceiver from Host Web

$
0
0

Hello,

I recently created an Autohosted App for Office 365/SharePoint 2013.

The App has an AppEventReceiver for Installed and Uninstalling Events. Within those AppEventReceivers I am trying to add a ListEventReceiver to a list within the host web.

The code I use to add an EventReceiver works fine:

EventReceiverDefinitionCreationInformation newEventReceiver = new EventReceiverDefinitionCreationInformation()
                            {
                                EventType = EventReceiverType.ItemAdding,
                                ReceiverName = "ReceiverItemAdding",
                                ReceiverUrl = remoteUrl,
                                SequenceNumber = 1000
                            };
                            oList.EventReceivers.Add(newEventReceiver);
                            clientContext.ExecuteQuery();

Unfortunately I am not able to delete the EventReceiver from the list. This is the code is use:

foreach (EventReceiverDefinition recDefinition in receiverColl)
                            {
                                if (recDefinition.ReceiverName.Equals("ReceiverItemAdding"))
                                {
                                    receiverIds.Add(recDefinition.ReceiverId);
                                }
                            }
                            foreach (EventReceiverDefinition receiver in receiverIds.Select(receiverColl.GetById))
                            {
                                receiver.DeleteObject();
                                clientContext.ExecuteQuery();
                            }

Whenever I perform the ExecuteQuery(), I receive an Access Denied error. It does not matter what permission I grant the app. Event Tenant permissions will cause an Access Denied error…

Regards and thank you in advance

Julian


Viewing all articles
Browse latest Browse all 8089

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>