Adding attachment to own record ower SM REST API from JS

Hello all,

After several days I was searching for a code which will consume SM REST API then after several tries and some help I generated below JS Code. 

var header = new Array();
header.push(new Header("Accept-Language", "en"));
header.push(new Header("Authorization", "Basic " lib.smis_RestClient.getBase64Encode("falcon:")));
header.push(new Header("Content-Disposition", 'attachment; filename=test.txt'));
header.push(new Header("Content-type","text/plain"));

var payload = "";

for (key in header) {
	payload =header[key].name ': ' header[key].value '\n';
}

var post_url = "">localhost:13080/.../attachments";

var body = "text file test";

payload ='\n' body;
print(payload);


try
{
	var result = doHTTPRequest("POST", post_url, header, body);
	print('POST result: ' result);
}
catch(e)
{
	print(e);
}