Set Media Type
Use the Set Media Typepolicy to define the content type. If the content type header is missing in a client request to an API, this policy adds the specified content type before the request is sent to the API.
Example of a Set Media Type policy.
kind: SetMediaType
apiVersion: api.webmethods.io/beta
metadata:
name: setMediaType
version: 1
namespace: sample
spec:
defaultContentType: ${request.path}
defaultAcceptHeader: ${request.httpMethod}
As part of the Set Media Type configuration, you can specify:
Type | Description |
---|---|
kind |
SetMediaType . Denotes the asset type, which is a Set Media
Type policy. |
apiVersion |
Denotes the version of the API in use. |
metadata |
Denotes the metadata or details of the asset type. It covers this metadata:
|
spec |
spec . Specifies the various policy properties that you can configure for
the policy.You can configure the following policy properties:
As both these properties support a variable framework, you can use the available variables to specify the content type and accept header. |