Skip to main content

I started doing some testing trying to make a request from Salesforce to a Mulesoft endpoint in  multipart/form-data. I'm wondering if there's a way to create the script in Salesforce for it,  I've created this script

 

%dw 2.0

input records application/java

output multipart/form-data

---

{

parts: {

text: {

content: "this is a content for text"

}

}

}

When calling the Apex script:

 

public static void processMultipart(){

DataWeave.Script script = new DataWeaveScriptResource.dataToMultipart();

Map<Id,Attachment> mapAttachments = new Map<Id,Attachment>([Select Id, Body from Attachment limit 10]);

DataWeave.Result result = script.execute(new Map<String, Object>{'records' => mapAttachments.values()});

System.debug('DW Result: '+ result.getValue());

}

Salesforce reports:

Is multipart/form-data supported?

Is there a sample for this, or maybe multipart/form-data is not supported yet?

 

Best!

4 answers
0/9000