使用REST错误-1002&创建组403禁止 [英] Create Group using REST error -1002 & 403 forbidden

查看:50
本文介绍了使用REST错误-1002&创建组403禁止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将下面的代码拼凑在一起,并导致错误号-1002,并且使用F12可以看到403被禁止.

Cobbled together the following code, and it results in an error number -1002 and, using F12 can see 403 forbidden. 

function CreateGroupREST(){
	var URL = 'https://gds.sharepoint.com'

	var executor = new SP.RequestExecutor(URL);
	
	var groupName = document.getElementById("txtGroupName").value
	if (groupName == '') {
		alert('Please enter a group name')
		return false;
		} //if
	
	executor.executeAsync({
	  url: URL+"/_api/SP.AppContextSite(@target)/web/sitegroups?@target='" + URL + "'",
	  method: "POST",
	  body: "{ '__metadata':{ 'type': 'SP.Group' }, 'Title':'" + groupName + "'}",
	  headers: { "content-type": "application/json; odata=verbose",
	  			 "X-RequestDigest": document.getElementById('__REQUESTDIGEST').value
	  			},
	  			 
	  success: alert("New Group Created"),
	  error: errorHandler
	});

	function errorHandler(data, errorCode, errorMessage) {
           alert("Failed to create group.\nError: " + errorCode + " - " + errorMessage);
       }
	
}

我想念什么?

What am I missing?

谢谢

史蒂夫·克拉克| 简易垃圾箱出租屋

奖金问题:为什么成功总是在失败之前触发?

Bonus Question: Why does the Success ALWAYS fire off before the failure?

推荐答案

您需要提供可在网站上创建组的应用权限.
请检查此链接SharePoint加载项权限
https://docs .microsoft.com/en-us/sharepoint/dev/sp-add-ins/add-in-permissions-in-sharepoint

You need to give the  App Permission that enables to create the group on site.
Please check this link SharePoint Add-in permission
https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/add-in-permissions-in-sharepoint


这篇关于使用REST错误-1002&创建组403禁止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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