While creating SharePoint group using Rest api, getting Microsoft.SharePoint.SPException with Error

Copper Contributor

Actual Error: body : "{"error":{"code":"-2146232060, Microsoft.SharePoint.SPException","message":{"lang":"en-US","value":"Exception from HRESULT: 0x80131904"}}}" statusCode : 500 statusText : "Internal Server Error".

Scenario: Actually In SharePoint online, By Rest API, My SharePoint Hosted app will create new list item and following that, create two groups, group 1 created successfully, while creating group 2 getting this above mentioned general error: 500 Internal server error.

Sample Code:

var metadata = JSON.stringify({ "__metadata": { "type": "SP.Group" },
"Title": "Group2 Members",
"Description": "Group2 Members",
"OnlyAllowMembersViewMembership": false,
"AllowMembersEditMembership": true
});
var url = CG_AppWebUrl + "/_api/SP.AppContextSite(@target)" + "/web/SiteGroups?" + "@target='" + CG_HostWebUrl + "'"
executor.executeAsync({
url: url,
method: "POST",
async: false,
body: metadata,
headers: {
"content-type": "application/json; odata=verbose",
"accept": "application/json; odata=verbose"
},
contentType: 'application/json',
success: function (data)
{
callback("Created");
},
error: function (data)
{
callback("Error");
}

 

App has Full Control permission in Site collection, Web and List. Executing User has Site collection admin access.

Note: This issue is not coming continuously, Randomly it is coming for different users with different roles.

Early I thought error occurred due to permission issue for different users, but now site collection admin user also getting this issue. And also I try to reproduce the issue by sending long group name, empty string in group name, same group name which gave for group 1, but the issue is not reproducing.

Anyone please give some alternate idea to reproduce the 500 internal serve error in SharePoint Hosted app.

 

Thanks in advance.

0 Replies