WSRetCode
Defines the HTTP success status sent in the REST response.
Syntax
WSRetCode= "{
code |
code:description }
"
Where
WSRetCode
is a string enclosed in quotations and where:- code can be:
- an HTTP code representing successful status in the range 200 to 399
- or the value "2XX", which is a specific code supported by the Swagger and OpenAPI specification to represent all response codes between 200 and 299, allowing the REST web service to return a code in this range dynamically at runtime with a call to the SetRestStatus method.
- description provides a description.
If you use the code option without a description, the default description
defined in RFC
2616 is returned to the client. If you use the code option with a
description, there is no space before or after the colon (:
).
WSRetCode
is an optional attribute.
Usage
You use WSRetCode
in the ATTRIBUTES()
clause of the REST
function to specify the HTTP protocol status in the response. The HTTP code and HTTP description you
provide is sent in the HTTP protocol response.
For examples setting the code
with the "2XX" value, go to com.WebServiceEngine.SetRestStatus.
Example using WSRetCode in REST function
In this trivial example, instead of "200 OK", the HTTP response is changed to "215 correct".PUBLIC FUNCTION Add(
a INTEGER ATTRIBUTES(WSQuery),
b INTEGER ATTRIBUTES(WSQuery) )
ATTRIBUTES(WSGet,
WSRetCode="215:correct" )
RETURNS INTEGER
RETURN a + b
END FUNCTION
![In the image the HTTP response is changed to 215 correct instead of 200 OK](Images/rest_response_with_wsretcode.png)