Example: set version with WSPath

You can set version using the WSPath attribute.

Example setting version in the path

In this example there are changes to the profile record type (profileType2) that are not compatible with the existing version of the API. The WSPath for the new function contains a version number (v2) that provides the path to the resource.

IMPORT com

TYPE profileType2 RECORD ... END RECORD

PUBLIC FUNCTION FetchMyUser2Profile(p_user_id INTEGER ATTRIBUTE(WSParam) )
  ATTRIBUTES(
    WSGet,
    WSPath="/users/v2/{p_user_id}",
    WSDescription="Returns a user profile for API v2 ",
    WSThrows="404:user not found"
    )
  RETURNS profileType2 ATTRIBUTES(WSName="data",
                                 WSMedia="application/json,application/xml")
    DEFINE p profileType2
    WHENEVER ERROR CONTINUE
    SELECT * INTO p.* FROM users
             WHERE user_id == p_user_id
    WHENEVER ERROR STOP
    IF SQLCA.SQLCODE==NOTFOUND THEN
        INITIALIZE p TO NULL
        CALL com.WebServiceEngine.SetRestError(404,NULL)
    END IF
    RETURN p.*
END FUNCTION
An example of the resource URL is:
http://host:port/gas/ws/r/group/xcf/Accounts/users/v2/1