Support for multipart request body
Send files and binary data in API requests by using the multipart form-data format.
webMethods Integration supports the multipart or form-data media type that uses which you can embed binary data such as files into the request body. Though application or x-www-form-urlencoded is a more natural way of encoding, it becomes inefficient for encoding binary data or text containing non-ASCII characters. The media type multipart/form-data is the preferred media type for request payloads that contain files, non-ASCII, and binary data.
For example, if you want to create a user as well as upload a photo, the request must be a multipart request where one part is an image file while the other part is a JSON request body. Uploading individual CRM contact data to Salesforce can be time-consuming. To streamline, you can use the MIME/Multipart attachments capability to upload a CSV or JSON file containing multiple contacts in a single run.
For some connectors and operations, for example, for SalesforceR bulk v2 data loader, DocuWare, Google drive, Amazon S3, and FreshService, IBM® webMethods integration supports a multipart request body.
Multipart request sample
A multipart/form-data request body includes several parts, which are separated by a boundary made up of a Carriage Return Line Feed (CRLF), two dashes (—), and the boundary parameter value. The boundary delimiter must not appear inside any of the encapsulated parts.
Each part has the Name, Type, Content-Type, and Part ID fields.
--BOUNDARY
Content-Type: application/json
Content-Disposition: form-data; name="job"
{
"object":"Contact",
"contentType":"CSV",
"operation":"insert"
}
--BOUNDARY
Content-Type: text/csv
Content-Disposition: form-data; name="content"; filename="content"
(Content of your CSV file)
--BOUNDARY—
Part configuration
While adding a custom action, for example, for the fresh service create Child Ticket With Attachments operation, you can click Attachments to view the list of all the configured parts to be sent to the service provider. You can send a multipart/form-data payload, which contains either a file, or text, or a document type.
The parts to be sent to the service provider appear in the input signature. All options including the Add option to add a custom part are disabled if the resource is not of type of multipart/form-data. Currently, multipart/form-data payload is supported at the request level, that is, in the input signature.
- Name. The name of the file part is as documented in the SaaS provider API documentation.
- Content Type. Specify the content type of the part: use TEXT for plain content, FILE for uploaded files, or DOCUMENT for serialized documents.
- Type . webMethods Integration defines three types of parts.
- TEXT. Represents a simple text part of a multipart/form-data payload where the content of the part is of type text/plain. You can use this part to send raw text data as the content of a part, in a multipart request. From a file upload perspective, this part is used to convey extra information about the upload behavior, like target folder paths or folder names where the file must be uploaded.
- DOCUMENT. Used when the part contains content of type
application/jsonorapplication/xml, as expected by some back-end systems - FILE. Represents a binary part of a multipart/form-data payload, containing either binary content or the file itself. Use this part to upload files. For file upload scenarios, this is the primary and required part that is expected by the service provider.
- Active/Inactive. Represents whether this part is included in the service signature.