RESTMessageV2 - setRequestBodyFromAttachment(String attachmentSysId)

Set the request body using an existing attachment record.

When you use this function with a REST message that is sent through a MID server, the MID server user must have any roles required to read attachment records.

Table 1. Parameters
Name Type Description
attachmentSysId String The sys_id of the Attachment [sys_attachment] record you want to send in this REST message.
Table 2. Returns
Type Description
void

(function sampleRESTMessageV2() {
    try {
        var request = new sn_ws.RESTMessageV2();
        request.setHttpMethod('post');
        request.setEndpoint('<web service endpoint URL>');
        request.setRequestBodyFromAttachment('<attachment sys_id>');
        
        var response = request.execute();
        var httpResponseStatus = response.getStatusCode();
      
        gs.print("http response status_code: " + httpResponseStatus);        
    }
    catch (ex) {
        var message = ex.getMessage();
        gs.print(message);
    }
})();