Passing an Attachment to through REST API to 3rd Party App from SN : Not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 01:05 PM
Hello Geeks,
I have built an outbound integration in Customer Service App to create a case record in Third Party Application (ServiceDeskPlus by Manage Engine) through REST API.
I need to send an attachment to the newly created record in SDP and I have written an BR on attachment table and triggering REST API call but getting below error with error code 500 in response status
{"response_status":{"status_code":4000,"messages":[{"status_code":4004,"type":"failed","message":"Internal error"}],"status":"failed"}}
BR On Attachment Table
On Insert - Async
Script in BR :
var resultGr = new GlideRecord("sn_customerservice_case");
resultGr.addQuery("sys_id", current.table_sys_id);
resultGr.addQuery("account", '<account sys id>'); // running for specific account
resultGr.query();
if (resultGr.next()) {
var caseid = resultGr.sys_id.toString();
gs.info("Case sys id : " + caseid);
try {
var r = new sn_ws.RESTMessageV2('New Integration', 'UploadAttachment');
r.setRequestBodyFromAttachment(current.sys_id);
r.setRequestHeader("Content-Type", resultGr.content_type);
r.setStringParameterNoEscape('request_id', resultGr.correlation_id);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.info("The value of the POST Response is " + httpStatus + "Body : " + responseBody);
} catch (ex) {
var message = ex.message;
}
}
Can you please help to identify where the issue is ?
NOTE : I have tried it through postman as well to send the attachment to the specified endpoint but same error.