0

我正在将我的 sharepoint 从 2013 迁移到 2019。在 sharepoint 2013 上运行良好的脚本在 sharepoint 2019 上引发了奇怪的错误。

{"error":{"code":"-1, Microsoft.SharePoint.Client.UnknownError","message":{"lang":"en-US","value":"Unknown Error"}}}

脚本是设置当前用户的头像。

function setMyProfilePicture(arrayBuffer) {
    var absoluteUrl = _spPageContextInfo.webAbsoluteUrl;
    var setPictureEndpoint = absoluteUrl + "/_api/SP.UserProfiles.PeopleManager/SetMyProfilePicture";
    $.ajax({
        url: setPictureEndpoint,
        type: "POST",
        data: arrayBuffer,
        processData: false,
        headers: {
            "accept": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),
            "content-length": arrayBuffer.byteLength
        },
        success: data => console.log(data),
        error: error => console.log(error.responseText)
    });
}

我尝试对 SP.RequestExecutor 对象做同样的事情,但错误仍然存​​在。最后我写了一个简单的powershell脚本,结果相同(未知错误)。

$context = new-object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$manager = new-object Microsoft.SharePoint.Client.UserProfiles.PeopleManager($context)

$personProps = $manager.getpropertiesfor($userAccountName)

$context.load($personProps)

$fs = new-object System.IO.FileStream($filePath, [System.IO.FileMode]::Open)
$manager.setmyprofilepicture($fs)

$context.load($manager)
$context.executequery()

不幸的是,我无法在另一台 sharepoint 2019 服务器上尝试此操作。

4

0 回答 0