Defines the data format of the REST message.


WSMedia = " MIME-type [,...]"
Where WSMedia is a comma-separated list of MIME types:
  1. MIME-type is a supported media type.
Note: A media type (also known as Multipurpose Internet Mail Extensions (MIME) type) is an identifier used by the HTTP protocol to denote message content. The format is based on standards from the Internet Assigned Numbers Authority (IANA).

WSMedia is an optional attribute.


You use this attribute to define the supported data format of the message. You set the WSMedia attribute in the ATTRIBUTE() clause of variables and/or on input and output function parameters.

The GWS chooses the format based on whether the Accept or Content-Type HTTP headers are set in requests and responses:
  • If the header is set, the GWS sets the data format accordingly provided the MIME type is listed in WSMedia. If the MIME type is not listed, the GWS returns a 400 No matching Rest operation found error.
  • If the header is not set, the GWS defaults to:
    • Selecting the first MIME type listed in WSMedia.
    • Or depending on the data type, selecting the appropriate default format for the type.
  • If WSMedia is not set, the GWS defaults to selecting the appropriate default format for denoting type of message content.
    Note: You can specify the format at runtime by calling the REST service engine option, for details see Setting MIME type at runtime.

Example: WSMedia with record variable

The example defines a record with a list of MIME types with WSMedia that allows the function handle different formats.

    "application/json, application/xml, application/x-www-form-urlencoded")
    a INTEGER,
    b FLOAT,
    c STRING

WSMedia and file attachments

If a file is to be attached, you can handle this through a parameter with a WSAttachment and the WSMedia attribute. For details, see Attach files with WSAttachment and WSMedia.