示例#1
0
 internal static ApiCall GetApiCall <TModel>(IDataModel <TModel> parent, ChangeQueryOptions query)
 {
     return(new ApiCall(GetApiCallUrl(parent), ApiType.SPORest, GetChangeQueryBody(query))
     {
         // We force this request to return verbose metadata as we need that information to determine the returned change token
         Headers = new Dictionary <string, string>
         {
             ["Accept"] = "application/json;odata=verbose"
         }
     });
 }
示例#2
0
        internal static string GetChangeQueryBody(ChangeQueryOptions query)
        {
            dynamic innerQuery = new
            {
                __metadata = new { type = "SP.ChangeQuery" },
                query.Activity,
                query.Add,
                query.Alert,
                query.ContentType,
                query.DeleteObject,
                // If we use a non-string, SharePoint yells at us about being unable to convert a primitive to Edm.Int64
                FetchLimit = query.FetchLimit.ToString(),
                query.Field,
                query.File,
                query.Folder,
                query.Group,
                query.GroupMembershipAdd,
                query.GroupMembershipDelete,
                query.IgnoreStartTokenNotFoundError,
                query.Item,
                query.LatestFirst,
                query.List,
                query.Move,
                query.Navigation,
                query.RecursiveAll,
                query.Rename,
                query.RequireSecurityTrim,
                query.Restore,
                query.RoleAssignmentAdd,
                query.RoleAssignmentDelete,
                query.RoleDefinitionAdd,
                query.RoleDefinitionDelete,
                query.RoleDefinitionUpdate,
                query.SecurityPolicy,
                query.Site,
                query.SystemUpdate,
                query.Update,
                query.User,
                query.View,
                query.Web
            }.AsExpando();

            if (query.ChangeTokenStart != null)
            {
                innerQuery.ChangeTokenStart = new
                {
                    __metadata = new { type = "SP.ChangeToken" },
                    query.ChangeTokenStart.StringValue
                };
            }

            if (query.ChangeTokenEnd != null)
            {
                innerQuery.ChangeTokenEnd = new
                {
                    __metadata = new { type = "SP.ChangeToken" },
                    query.ChangeTokenEnd.StringValue
                };
            }

            dynamic bodyQuery = new ExpandoObject();

            bodyQuery.query = innerQuery;

            return(JsonSerializer.Serialize(bodyQuery as ExpandoObject, PnPConstants.JsonSerializer_IgnoreNullValues));
        }