Integration Server (Handling multipart request OpenAPI)

Introduction

In the case of multipart requests, one or more different sets of data are combined in a single body, where the content type starts with “multipart”. The body of the request contains one or more “body parts,” each preceded by a boundary. Each part mainly having:

- starts with a boundary

- and then the body part consisting of the header area

- body area

Example:

 Content-Type: multipart/mixed;

      boundary=myBoundaryValue

This means the body is having several parts, each part is mostly syntactically identical to an RFC 822 message, except that the header area might be completely empty, and that the parts are each preceded by the line

 --myBoundaryValue

There are different sub-types of a multipart request, like form-data, mixed, alternative, related, digest, etc.

As of now, webMethods Integration Server (OpenAPI provider and consumer supports only form-data and mixed subtype).

How a multipart request looks like (from postman client)

Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Authorization: Basic
Content-Length: 487

----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name=“id”
Content-Type: text/plain

SAG123
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name=“address”
Content-Type: application/json

{“city”:“myCity”, “street”:“myStreet”}
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name=“profileImage”; filename="/C:/Users/PMAL/OneDrive - Software AG/Desktop/fp.jpg"
Content-Type: image/jpeg

(data)
----WebKitFormBoundary7MA4YWxkTrZu0gW

Multipart request

In Multipart request the request will have multiple parts to it like a JSON string along with file content and a few primitive type data as part of a single request, also content types are applied to different parts of a multipart request separated by defined boundaries. As per spec if no content-type is defined for the said parts, we should consider this as the default content type

  • Primitive, or an array of primitive values, the default Content-Type is text/plain
  • Complex types (Object), or an array of complex values (Object arrays), the default Content-Type is application/JSON
  • type: string with format: binary or format: base64, the default content type is application/octet-stream

This is how the request and service signature looks like

image

image

Multipart provider demo

multipartProvider

Multipart consumer demo

multipartConsumer

1 Like