3

I have found this example of how to write a custom REST API to accept binary data.

@HttpPut global static String updateCase(RestRequest req) {
    String companyName = req.params.get('companyName');
    Account company = [ Select ID, Name, Type, BillingState from Account where Name = :companyName];

    Attachment a = new Attachment();
    a.ParentId = company.Id;
    a.Name = 'test.png';
    a.Body = req.requestBody;

    insert a;

    return 'Attachment added'; }

What I want to do is to accept a MIME/MULTIPART message which may have one or more binary parts. The use case is to allow attaching multiple attachment to a record with one REST API call. Is this supported in custom Rest APIs? I have not been able to find any examples of this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.