Recently I had an issue with a SharePoint Remote Event Receiver that was returning a 404 error.
I had given correct permission in the appmanifest.xml.
The clientcontext was being created with the following code:
var webUrl = properties.ItemEventProperties.WebUrl; Uri webUri = new Uri(webUrl); var realm = TokenHelper.GetRealmFromTargetUrl(webUri); var accessToken = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, webUri.Authority, realm).AccessToken; using (ClientContext clientContext = TokenHelper.GetClientContextWithAccessToken(webUrl, accessToken)) ...
After digging around I discovered that newer SharePoint Online sites have app only permissions disabled. To enable it I ran the following powershell commands:
Connect-SPOService -URL "https://<url>-admin.sharepoint.com" Set-SPOTenant -DisableCustomAppAuthentication $false
After this, my remote event receiver started working.