This article gives an overview on the usage of custom content-type in webMethods API Gateway. Content types are used to define the type of the content. Custom content types can be used to define rules for the payload.
Below are sample use cases when custom content type is useful.
1. Versioing of APIs – Where different versions of the APIs use different payloads.
Content-type = application/vnd.sample.api.v1+json
Content-type = application/vnd.sample.api.v2+json
2. When predefined rules exists as part of Payload
Example: Content-Type: application/vnd.bmw.car+json
, "color": "blue"
, "hp": 160
, "model" "X1"
, "type": "SUV"
1. An active webMethods API Gateway tenant.
2. An API hostedon your webMethodsAPI Gateway tenant.
An API Provider can configure custom content-types based on how the payloads in the incoming or outgoing requests have to be processed. If the native API consumes a custom content-type, the API Provider can configure a mapping between this custom content-type and a base content-type so that the schema validation, and identification in the policies are performed based on the base type.
Custom content type = application/vnd.mycorp.mydatatype+json
Base Content Type = application/json
1. Login to your webMethods API Gateway tenant
2. Go to `Administration` . From the `General Tab` Select `Custom Content-Type`.
3. Provide the `Content Type` and `Base Type` and `Add`.
4. Now Navigate to API and select an API where you want to add `Custom Content Type`.
`5. Edit` the API and click on `Policies` tab.
6. Under ` Policies` go to `Request processing` and Click `Validate API Specification`.
7. Now from the right window check `Content Types`. Save the API
** For example, a native API consumes application/vnd.ford.car+json content-type. The API provider creates an API for this native API and enforces the Validate API Specification policy and the API definition has schema mapping for application/json. When the request reaches API Gateway and as there is no content-type schema mapping for application/vnd.ford.car+json, the schema validation is skipped. In such scenarios, if the API provider creates a custom content-type mapping in the API Gateway UI with the content type as application/vnd.ford.car+json and base type as JSON, then the payload in the incoming request is validated against the application/json schema.