0

I have the following issue. I 've developed a provider hosted app with remote event receivers. I can access content on the app (lists created in the app) and also office 365 properties.

But i want to access a list created on host web.

On edit of an item, i want to add that item into a calendar on host web.

I use this code :

 using (ClientContext clientContext = /*clientContextTest*/TokenHelper.CreateAppEventClientContext(propertiesFunction,false))
        {

            if (clientContext != null)
            {
                List calendarList = clientContext.Web.Lists.GetByTitle("LeaveCalendar");

                clientContext.Load(calendarList);
                clientContext.ExecuteQuery();

                ListItemCreationInformation calendaritemCreationInfo = new ListItemCreationInformation();

                ListItem calendarItem = calendarList.AddItem(calendaritemCreationInfo);

                calendarItem["Title"] = "Leave Request for " + requesterName + " for " + Convert.ToString(workDaysRequested) + " day(s)";
                calendarItem["EventDate"] = startDate;
                calendarItem["EndDate"] = endDate;
                calendarItem.Update();

                clientContext.ExecuteQuery();
            }
        }

However the client context returns null. I used the CreateAppEventClientContext because is the one specified to access host web content.

What am i doing wrong?

0

If you want to create Remote Event Receiver for List on Host Web, the following articles for your reference:

Attaching Remote Event Receivers to Lists in the Host Web

Attaching Remote Event Receivers to Lists in the Host Web

Remote Event Receiver (RER) for Host Web using SharePoint Provider Hosted App in Office 365/SharePoint Online Environment

Remote Event Receiver (RER) for Host Web using SharePoint Provider Hosted App

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.