Skip to content

Instantly share code, notes, and snippets.

@wictorwilen
Last active October 16, 2018 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wictorwilen/1aa4d3ae2b0636ae9a893986bd00fd23 to your computer and use it in GitHub Desktop.
Save wictorwilen/1aa4d3ae2b0636ae9a893986bd00fd23 to your computer and use it in GitHub Desktop.
Client side updates of SharePoint stuff
fetch('/_api/site', {headers:{accept:'application/json'}}).then( x => x.json().then( y => console.log(y)))
fetch('/_api/web', {headers:{accept:'application/json'}}).then( x => x.json().then( y => console.log(y)))
fetch('/_api/contextinfo',
{method:'POST', headers: { "Accept": "application/json; odata=verbose"}}).then( r =>
r.json().then( d => {
console.log(d.d.GetContextWebInformation.FormDigestValue)
fetch('/_api/web',
{method:'POST', headers:{'content-type':'application/json;odata=verbose',accept:'application/json;odata=verbose','X-RequestDigest':d.d.GetContextWebInformation.FormDigestValue, 'x-http-method':'MERGE'},
body: JSON.stringify({
HeaderEmphasis:3, // 0-3
HeaderLayout:2, // 0-2
MegaMenuEnabled: true,
"__metadata":{"type":"SP.Web"}})}).then( x =>
console.log(x)
)
}
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment