Forum Discussion
bhartisemwal1990
Nov 23, 2016Copper Contributor
Problem in Deleting Remote Event Receiver in Sharepoint
Hi , I have attached Remote event Receiver to a document library using Provider hosted app.Now i am trying to delete (Provider hosted app) the same remote event Receiver but i am getting "Micros...
Anonymous
Nov 23, 2016You can do this first by searching it in the SharePoint ClientBrowser and then use a powershell script to delete it.
function Get-SPOListEventreceivers { param ( [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] $AdminPassword, [Parameter(Mandatory=$true,Position=3)] [string]$Url, [Parameter(Mandatory=$true,Position=4)] [string]$ListTitle, [Parameter(Mandatory=$true,Position=5)] [GUID]$EventReceiverGUID ) $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) try { $ctx.ExecuteQuery() } catch [Net.WebException] { Write-Host $Url " failed to connect to the site" $_.Exception.Message.ToString() -ForegroundColor Red } $ctx.Load($ctx.Site) $lista=$ctx.Web.Lists.GetByTitle($ListTitle) $ctx.Load($lista) $ctx.ExecuteQuery() $recevery=$lista.EventReceivers $ctx.Load($recevery) $ctx.ExecuteQuery() Write-Host "Found " $recevery.Count " receivers in " $lista.Title $recevery.GetById($EventReceiverGUID).DeleteObject() try { $ctx.ExecuteQuery() Write-Host "receiver removed" } catch [Net.WebException] { Write-Host "Failed to delete the receiver" $_.Exception.Message.ToString() -ForegroundColor Red } } # Paths to SDK. Please verify location on your computer. Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" # Insert the credentials and the name of the admin site $Username="spadmin@xxx.onmicrosoft.com" $password = "$xxxx" $url = "https://xxxx.sharepoint.com/sites/S046WW16776" $AdminPassword=Read-Host -Prompt "Password" -AsSecureString $Url="https://xxx.sharepoint.com/sites/S046WW16776" $ListTitle="Project Metadata" $EventReceiverGUID="8ded46d9-6b87-4dac-9532-64d013122e92" Get-SPOListEventreceivers -Username $Username -AdminPassword $AdminPassword -Url $Url -ListTitle $ListTitle -EventReceiverGUID $EventreceiverGUID
bhartisemwal1990
Nov 24, 2016Copper Contributor
yeah i think now powershell is the only option .
Because the issue was not with the appid change but the farm id change because of which the entire AppId was not matching and hence giving access denied error.
Thanks for replies :)