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.

You write the service, so a request body arrives as input to your function and a response body is what your function returns as output.

Table 1 lists the HTTP verbs and their corresponding RESTful high-level API attributes, with the message bodies each verb accepts. The Request body and Response body columns describe what the function definition can declare.
Table 1. HTTP verbs and attributes
HTTP Verb REST API attribute Request body Response body
GET WSGet Not allowed Allowed
HEAD WSHead Not allowed Not allowed
POST WSPost Required 1 Allowed
PUT WSPut Required 1 Allowed
DELETE WSDelete Not allowed Allowed
OPTIONS WSOptions Not allowed Allowed
TRACE WSTrace Not allowed Not allowed
PATCH WSPatch Required 1 Allowed 2

1. The function must declare an input body parameter. To let a client call the service without a request body, set the WSOptional attribute on that parameter.

2. Starting from FGLGWS 4.01.11, 5.01.07, and 6.00.03. In earlier versions, a WSPatch function with a response body raises error -9129.

You do not need to remember every combination. The fglcomp tool reports a function whose message bodies do not match its verb:

  • A WSPost, WSPut, or WSPatch function with no input body parameter raises error -9106.
  • A WSGet, WSHead, WSDelete, WSOptions, or WSTrace function with an input body parameter raises error -9128.
  • A WSHead or WSTrace function with a response body raises error -9129.

Function prototype example

A function's attributes 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),
    # ...
    )
    ATTRIBUTES(
       WSGet,
       WSPath = '/{parameter-name}/hello',
       WSThrows = "404:not found, 500:Internal Server Error",
       WSDescription = "Returns an integer and a greeting",
       WSVersion = "v2, v3",
       # ...
       )
     RETURNS ( INTEGER, STRING )
     # ... function code
    
END FUNCTION
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 (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.