用于访问主机Web内容的远程事件接收器返回null [英] Remote event receiver for accessing host web content returns null

查看:87
本文介绍了用于访问主机Web内容的远程事件接收器返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我有以下问题.我已经开发了带有远程事件接收器的提供程序托管的应用程序.我可以访问应用程序上的内容(在应用程序中创建的列表)以及Office 365属性.

但是我想访问在宿主网站上创建的列表.

在编辑项目时,我想将该项目添加到宿主网站上的日历中.

我使用此代码:

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();
                }
            }



但是,客户端上下文返回null.我使用了CreateAppEventClientContext,因为它是用于访问主机Web内容的指定对象.

我在做什么错了?



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?

推荐答案

请检查您的加载项权限是否有权访问主机

Please check your Add-In Permission has access to host web and list as outlined here


这篇关于用于访问主机Web内容的远程事件接收器返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆