Micro Focus Expert
Micro Focus Expert

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 = "http://localhost:13080/SM/9/rest/incidents/IM10002/attachments";

var body = "text file test";


	var result = doHTTPRequest("POST", post_url, header, body);
	print('POST result: '+result);
1 Reply
Honored Contributor.
Honored Contributor.


since you didn't state your question I'm going to assume that is the one in the title. if you want to work with attachments with REST, please check out the following link.




hope this guides you.


Best Regards

If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the STAR at the bottom left of the post and show your appreciation.
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.