ItemAdded remote event Receiver return clientcontext Null working fine on other same level webs pages library, i used TokenHelper class for get content on behalf of current login user, i tried to use Admin account as well if Client context null but that also not work , i tried to detach and attach again on new libraries but still null.

I tried below ways but no success:

  1. ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties)

working fine in other webs but not working on new Web Library under same site collection.

  1. // obtain web URL somehow - line below is fine for a list item RER, but you'll need another approach elsewhere:
string webUrl = properties.ItemEventProperties.WebUrl;

Uri webUri = new Uri(webUrl);

string realm = TokenHelper.GetRealmFromTargetUrl(webUri); 
string accessToken = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, webUri.Authority, realm).AccessToken; 
using (var clientContext = TokenHelper.GetClientContextWithAccessToken(webUrl, accessToken))  
    // do CSOM stuff here..

this way showing item may be deleted or checkout by other user.

Please let me know if any other way to fix this issue .

New contributor
Shivani is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

Shivani is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.