I have been reading around all kinds of documentation and posts and haven't been able to wrap my head around what I need to accomplish my goal. What I am trying to achieve is to write a custom Apex REST web service that allows an the invoking application to create a new custom object record, and at the same time submit a list of file attachments to be latched onto the newly created record.

I have written a few services that create a new record from a REST post, so that isn't the hindrance, but rather the part where I try to include file attachments. My initial assumption was to just include a List in the definition of parameters, but that doesn't seem to be allowed in a http service.

Any nudges in the right direction would we wildly appreciated :)

A stripped down sample of my current code below:

global with sharing class WS_WarrantyClaims{

global class ParamData{
public String strWONumber;
public String strCompanyName;
public String strCompanyAddress;

public String strFailureDescription;
public Date dDeliveryDate;
public Integer iProductionHours;

public List<Blob> attachments;

global class ReturnData{
  String strStatus;
  String strErrorMessage;
  String strClaimId;

global static ReturnData doPost(ParamData params){
  ReturnData retData = new ReturnData();

  WarrantyClaim__c wc = new WarrantyClaim__c();
  wc.ltClaimDescription__c = params.strFailureDescription;

    insert wc;
    retData.strStatus = 'Success';
    retData.strClaimId = wc.Id;
 catch( Exception e ){
    retData.strStatus = 'Error';
    retData.strErrorMessage = e.getMessage();

 return retData;
| improve this question | | | | |

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.