【问题标题】:User does not exist error while adding user to SharePoint group via REST API post request ajax通过 REST API 发布请求 ajax 将用户添加到 SharePoint 组时用户不存在错误
【发布时间】:2020-07-02 14:34:42
【问题描述】:
function addthisuser(){
    var data = {
        __metadata: { 'type': 'SP.User' },
        'LoginName': "martin.newman@sharepoint.com"
    };
    $.ajax({
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/SiteGroups/GetByName('HRGroupSharePoint')/users",
        method: "POST",
                        data: JSON.stringify(data),
                        headers: { 'Accept': 'application/json;odata=nometadata',  
                        'Content-type': 'application/json;odata=verbose',  
                        'odata-version': ''                                  
        },
        success: function (data) {
            debugger;
            alert('Item added successfully');
        },
        error: function (error) {
            debugger;
            alert("Error: "+ JSON.stringify(error));
        }
    }); 
}

使用上述POST 请求添加用户(针对LoginName 的硬编码电子邮件)以错误结尾,提示“用户不存在或不是唯一的”。如果上面指定的用户被授予对整个站点的读取权限作为唯一权限,则错误仍然存​​在... LoginName 格式是否错误?标题有什么问题吗?

【问题讨论】:

    标签: javascript rest api sharepoint sharepoint-online


    【解决方案1】:

    LoginName 必须是 person 列的 Key 属性,例如i:0#.w|rib.johnson@domain.com

    【讨论】:

      猜你喜欢
      • 2021-10-03
      • 2023-03-29
      • 1970-01-01
      • 1970-01-01
      • 2021-10-19
      • 1970-01-01
      • 1970-01-01
      • 2016-11-26
      • 2022-01-20
      相关资源
      最近更新 更多