WSPut
In order to update an existing resource, you set the WSPut attribute
Syntax
WSPut
Usage
You use this attribute to specify the action of the HTTP verb PUT to update an existing resource.
You set the WSPut
attribute in the ATTRIBUTES()
clause of the
function.
Example WSPut to update a user record
TYPE profileType RECORD
id INT,
name VARCHAR(50),
email VARCHAR(100)
END RECORD
PUBLIC FUNCTION UpdateUserProfile(
id STRING ATTRIBUTE(WSParam),
thisUser profileType )
ATTRIBUTES (WSPut,
WSPath="/users/{id}",
WSThrows='404:user not found')
RETURNS STRING
DEFINE ret STRING
# ... function code ...
LET ret = SFMT("Updated user with ID: %1",id)
RETURN ret
END FUNCTION
In this example, a resource is updated.
thisUser
is data passed in the message
body in either JSON or XML format. An example of the resource URL shows xxx
as the
user id replaced in the 4GL
function.http://host:port/gas/ws/r/xcf/users/xxx