In an Angular5 application in SharePoint Online we generate 2 subsites based on user input vía the REST API using previously saved site templates:
updateNewAPP(newAPP: Anteproyecto, tmplAnteProyecto: string, tmplInfoCliente: string) {
const bodyObj = {
'__metadata': { 'type': 'SP.Data.Proyectos_x0020_AnteproyectosListItem' },
'N_x00ba__x0020_de_x0020_anteproy': newAPP.noDeAnteproyecto,
'Title': newAPP.title
};
const bodyObj2 = {
'parameters': {
'__metadata': { 'type': 'SP.WebInfoCreationInformation' },
'Url': newAPP.noDeAnteproyecto,
'Title': newAPP.noDeAnteproyecto,
'Description': newAPP.title,
'Language': 3082,
'WebTemplate': tmplAnteProyecto,
'UseUniquePermissions': false
}
};
const bodyObj3 = {
'parameters': {
'__metadata': { 'type': 'SP.WebInfoCreationInformation' },
'Url': newAPP.noDeAnteproyecto + '-InfoCliente',
'Title': newAPP.noDeAnteproyecto + '-InfoCliente',
'Description': newAPP.title + ' - Info Cliente',
'Language': 3082,
'WebTemplate': tmplInfoCliente,
'UseUniquePermissions': false
}
};
return Observable.forkJoin(
this._sharepointService.SPUpdateItem('Proyectos Anteproyectos', bodyObj, newAPP.id.toString()),
this._sharepointService.SPAddSubsite(bodyObj2),
this._sharepointService.SPAddSubsite(bodyObj3)
);
}
where SPAddSubSite() sends a POST to the /_api/web/webinfos/add endpoint. On successful return of the observables the next step in the code generates a single item in a list in both of the new subsites:
addLinksNewAPP(newAPP: Anteproyecto) {
const observables = [];
const bodyObj = {
'__metadata': { 'type': 'SP.Data.EnlacesListItem' },
'Title': newAPP.noDeAnteproyecto + '-InfoCliente',
'enlace': {
'__metadata': { 'type': 'SP.FieldUrlValue' },
'Description': newAPP.title + ' - Info Cliente',
'Url': _spPageContextInfo.webServerRelativeUrl + this.urlPrefix + newAPP.noDeAnteproyecto + '-InfoCliente'
}
};
observables.push(this._sharepointService.SPAddItemSubSite('Enlaces', bodyObj, newAPP.noDeAnteproyecto));
const bodyObj2 = {
'__metadata': { 'type': 'SP.Data.EnlacesListItem' },
'Title': newAPP.noDeAnteproyecto,
'Enlace': {
'__metadata': { 'type': 'SP.FieldUrlValue' },
'Description': newAPP.title,
'Url': _spPageContextInfo.webServerRelativeUrl + this.urlPrefix + newAPP.noDeAnteproyecto
}
};
observables.push(this._sharepointService.SPAddItemSubSite('Enlaces', bodyObj2, newAPP.noDeAnteproyecto + '-InfoCliente'));
return Observable.forkJoin(observables);
}
where SPAddItemSubSite sends a POST to the /...subsitio.../_api/web/lists/getByTitle('listname')/items endpoint. The process then continues only after receiving a successful reply from the REST calls to further modify the subsites.
Usually this process works correctly taking between 30 and 45 seconds for the 2 subsites to be generated, but occasionally (about 1 in 10) after the subsites are generated, one of the next 2 REST calls to create the items in the lists in the subsites fails with a 500 and the error message:
code: "-2146262060, Microsoft.SharePoint.SPException"
message: {lang:"es-ES", value: "Exception from HRESULT: 0x80131904"}
In previous versions of SharePoint this exception code indicated a problem with SQL Server such as low disk space - a troubleshooting list about the code and it's possible causes can be found here - https://social.technet.microsoft.com/wiki/contents/articles/37416.sharepoint-20132010-troubleshooting-exception-hresult-0x80131904.aspx
None of these reasons seems to fit with this case as the process usually works correctly, failing only about a tenth of the time.
Office365 support were unable to help (the REST API is NOT covered by them) but they suggested it may be related to permissions.
As this error occurs only occasionally and seems to be triggered immediately after the subsite creation I suspect that the successful return of the REST calls to create the sites may be sent too early, before the sites have been fully generated.
Does anybody know if my suspicion is correct or if anybody has had any similar experiences attempting to modify a site immediately after it has been created? Is there a way of detecting when a site has been fully generated apart from the response from the REST call which creates the site?
Is there some other reason why we may be seeing this error only some of the times?
User contributions licensed under CC BY-SA 3.0