Set a request body
Input parameters not specified with attributes are sent in the body of the HTTP PUT or POST request.
A message body is required when you perform an HTTP PUT or POST request to a resource, otherwise the request results in the error-9106.
If your function needs to create or update a resource, then you will need to set the request body for the incoming payload.
In your 4GL function, you declare an input parameter without any of the REST parameter attributes
(WSHeader
, WSQuery
, WSCookie
). If you have more
than one of such input parameters, it means your payload is delivered in a multipart form-data body
request.
The function needs to receive data of the required structure for the resource in either a JSON or XML representation. If the data type is not a primitive data type, you may need to define a type suitable for the structure in your module. You reference the type in your input parameter. For an example, see Example: create resource with WSPost.
In this example the single input parameter ("coef
") is not defined with a REST
attribute and its content is therefore sent in the body of the HTTP request.
Example specifying a request body
PUBLIC FUNCTION add(
a INTEGER ATTRIBUTE(WSQuery),
b INTEGER ATTRIBUTE(WSQuery),
coef FLOAT)
ATTRIBUTES (WSPost,
WSPath='/add')
RETURNS FLOAT
RETURN (a + b) * coef
END FUNCTION