Created
December 19, 2024 06:10
-
-
Save ktskumar/aed8f3cf871fe719d1bfb4ab37af437c to your computer and use it in GitHub Desktop.
Javascript code to create a site collection app catalog from browser console
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// POST request Call | |
function RestRequest(url, params) { | |
var req = new XMLHttpRequest(); | |
return new Promise(function(resolve, reject) { | |
req.onreadystatechange = function() { | |
if (req.readyState != 4) // Loaded | |
return; | |
if (req.status >= 200 && req.status < 300) { | |
resolve(req); | |
} else { | |
reject({ | |
status: req.status, | |
statusText: req.statusText | |
}); | |
} | |
}; | |
var webBasedUrl = url; | |
req.open("POST", webBasedUrl, true); | |
req.setRequestHeader("Content-Type", "application/xml"); | |
req.setRequestHeader("x-requestdigest", _spPageContextInfo.formDigestValue); | |
req.send(params ? params : void 0); | |
}); | |
} | |
function createsiteappcatalog(adminurl,siteurl){ | |
RestRequest(adminurl+'/_vti_bin/client.svc/ProcessQuery', '<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="SharePoint Designs Application" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="38" ObjectPathId="37" /><ObjectPath Id="40" ObjectPathId="39" /><ObjectPath Id="42" ObjectPathId="41" /><ObjectPath Id="44" ObjectPathId="43" /><ObjectPath Id="46" ObjectPathId="45" /><ObjectPath Id="48" ObjectPathId="47" /></Actions><ObjectPaths><Constructor Id="37" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /><Method Id="39" ParentId="37" Name="GetSiteByUrl"><Parameters><Parameter Type="String">'+siteurl+'</Parameter></Parameters></Method><Property Id="41" ParentId="39" Name="RootWeb" /><Property Id="43" ParentId="41" Name="TenantAppCatalog" /><Property Id="45" ParentId="43" Name="SiteCollectionAppCatalogsSites" /><Method Id="47" ParentId="45" Name="Add"><Parameters><Parameter Type="String">'+siteurl+'</Parameter></Parameters></Method></ObjectPaths></Request>').then(function(resp) { | |
console.log(resp); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment