【发布时间】:2016-04-13 17:56:21
【问题描述】:
我正在尝试将单击 SharePoint(在线)网站中的按钮的用户添加到 Office 365 组。我知道这可以通过 JSON 使用 Add Member API 来完成。
然而,当谈到 JSON 并不断搞乱 POST 函数时,我真的很缺乏经验。这是我目前拥有的代码,逗号之前的所有内容都可以正常工作。
function showButton() {
$('btn-1').on('click', function(event) {
var userProfileProperties
var clientContext = new SP.ClientContext.get_current();
var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
userProfileProperties = peopleManager.getMyProperties();
clientContext.load(userProfileProperties);
clientContext.executeQueryAsync(onSuccess, onFail);
function onSuccess(){
accountProperties = userProfileProperties.get_userProfileProperties();
accountId = accountProperties['msOnline-ObjectId'];
//JSON Query
jQuery.ajax({
url: "https://mysite.sharepoint.com/groups/groupID/members/$ref";
method: "POST";
contentType: "application/json";
dataType: 'json',
{
"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/" + accountId
};
});
};
function onFail(){
alert(failed);
};
});
};
【问题讨论】:
标签: javascript json sharepoint office365 sharepoint-online