HTTP verbs and attributes

HTTP verbs are defined by the high-level RESTful attributes. Some verbs have requirements for request or response body and others do not.

Table 1 lists the HTTP verbs and their corresponding RESTful high-level API attributes. The Request body required column identifies those verbs that require an input message body, and the Response body allowed column identifies those verbs that do not allow an output message body.
Table 1. HTTP verbs and attributes
HTTP Verb REST API attribute Request body required? Response body allowed?
GET WSGet No Yes
POST WSPost Optional Yes
PUT WSPut Optional Yes
DELETE WSDelete No Yes
PATCH WSPatch Optional No

In summary:

  • POST, PUT, and PATCH requests are verbs that typically require an input message body, and failing to specify a message body in a request will raise error-9106 or error-9128. You can, however, define the input body parameter as optional by setting the WSOptional attribute on the input parameter. With the body parameter defined as optional, an input body request is not required when a client calls the service.
  • HEAD, TRACE, and PATCH responses do not allow an output message body. Specifying these responses with a message body will raise error-9129.

When you compile your Web service application, the fglcomp tool checks that attributes comply with these requirements.

Function prototype example

A function's attributes property determine the HTTP verb, the resource path, and more. Table 2 lists and describes the attributes you can use in the ATTRIBUTES clause of the function.

PUBLIC FUNCTION function-name(
    parameter-name INTEGER ATTRIBUTES(WSParam),
    # ...
       WSPath = '/{parameter-name}/hello',
       WSThrows = "404:not found, 500:Internal Server Error",
       WSDescription = "Returns an integer and a greeting"
       WSVersion = "v2, v3"
       # ...
     # ... function code
Table 2. Function attributes
Attribute type Description
HTTP verbs and attributes

An HTTP verb action specifying the operation on a REST resource.

WSPath Slash-separated list of path elements and/or value templates identifying the resource URL.
WSDescription Textual description of the function.
WSThrows Colon-separated list of error-definitions as HTTP status code, and/or code with description.
WSRetCode Colon-separated HTTP status success code with description.
WSScope access (function) A comma-separated list of security scopes giving access to the resource.
WSVersion (function) A comma-separated list of version names specifying the versions of the Web service in which the operation will be accessible to clients.