Get - Delete Docs

by dshilkret

HTML

<div id="response">
Response
</div>
<input type="button" id="button" value="Get" />
<input type="button" id="clear" value="Clear" />

JavaScript

var requestBody = ""; 

var client=new XMLHttpRequest();
function getDocs()
{
client.open("get","https://dev29198.service-now.com/api/now/table/x_150952_sharepoin_sharepoint_attachment_table?sysparm_fields=sys_id&sysparm_limit=10");

client.setRequestHeader('Accept','application/json');
client.setRequestHeader('Content-Type','application/json');

//Eg. UserName="admin", Password="Felicity1!" for this code sample.
client.setRequestHeader('Authorization', 'Basic '+btoa('admin'+':'+'Felicity1!'));

client.onreadystatechange = function() { 
	if(this.readyState == this.DONE) {
		document.getElementById("response").innerHTML=this.status + this.response; 
	}
}; 
client.send(requestBody);
}
function deleteDocs(sysId)
{
var requestBody = ""; 

var client=new XMLHttpRequest();
client.open("delete","https://dev29198.service-now.com/api/now/table/x_150952_sharepoin_sharepoint_attachment_table/9950b79b4ff1530099f1b2718110c781");

client.setRequestHeader('Accept','application/json');
client.setRequestHeader('Content-Type','application/json');

//Eg. UserName="admin", Password="admin" for this code sample.
client.setRequestHeader('Authorization', 'Basic '+btoa('admin'+':'+'Felicity1!'));

client.onreadystatechange = function() { 
	if(this.readyState == this.DONE) {
		document.getElementById("response").innerHTML=this.status + this.response; 
	}
}; 
client.send(requestBody);
}


$('#button').click(function() {
    getDocs();
});
$('#clear').click(function() {
    deleteDocs('db5e201b4fbd130099f1b2718110c72a');
});