Functions are custom formulas that can be used in reports to manipulate data. Only custom functions can be edited, not the built-in functions.
Note. All requests require Session Id URL parameter and basic request headers. In the following examples, headers are omitted for clarity.
Functions are represented as JSON objects with the following properties:
Name | Type | Writeable | Description |
Id | string | required-create | The unique Id of this function |
Description | string | yes | The description of this function |
MinArgs | integer | yes (0) | Minimum number of arguments for this function |
MaxArgs | integer | yes (0) | Maximum number of arguments for this function |
Language | enum | yes | Code Language |
Namespaces | array of strings | yes | Namespaces for this function |
References | array of strings | yes | References for this function |
ProgramCode | string | yes | Function code |
IsCustom | boolean | no | Whether this is a custom function |
{ "Id": "DayOfWeek", "Description": "Returns the day of the week as a string given a date value", "MinArgs": 1, "MaxArgs": 1, "Language": "cs", "Namespaces": [], "References": ["System.dll"], "ProgramCode": "return System.Convert.ToDateTime(args[0].ToString());", "IsCustom": true }
GET /rest/functions
List all the functions in the current configuration. Output is an array of objects, each representing an individual function.
Name | Type | Description |
Id | string | The unique Id of this function |
Name | Type | Description |
filter | string | Possible values: custom - Return only custom functions. |
curl http://{webservice}/rest/functions?sid={sid} -X GET
Status: 200 OK
[
{
"Id": "Today"
},
{
"Id": "Tomorrow"
},
...
]
GET /rest/functions/{Id}
Show the properties of the function specified by its Id.
curl http://{webservice}/rest/functions/{Id}?sid={sid} -X GET
Status: 200 OK
{ "Id": "Today", "Description": "", "MinArgs": 0, "MaxArgs": 0, "Language": "cs", "Namespaces": [], "References": [], "ProgramCode": "return sessionInfo.Today;", "IsCustom": true }
POST /rest/functions
curl http://{webservice}/rest/functions?sid={sid} -X POST ^ -d @customFunction.txt
customFunction.txt
"{'Id':'DayOfWeek','Description':'Returns the day of the week as a string given a date value','MinArgs':1,'MaxArgs':1,'References':['System.dll'],'ProgramCode':'return System.Convert.ToDateTime(args[0].ToString());'}"
Status: 201 Created
Location: /{webservice}/rest/Functions/DayOfWeek
{ "Id": "DayOfWeek", "Description": "Returns the day of the week as a string given a date value", "MinArgs": 1, "MaxArgs": 1, "Language": "cs", "Namespaces": [], "References": ["System.dll"], "ProgramCode": "return System.Convert.ToDateTime(args[0].ToString());", "IsCustom": true }
PATCH /rest/functions/{Id}
Only supply the properties to be edited. Only custom functions can be edited.
curl http://{webservice}/rest/functions/{Id}?sid={sid} -X PATCH ^ -d "{'Namespaces':['WebReports.Api']}"
Status: 204 No Content
DELETE /rest/functions/{Id}
Only custom functions can be deleted.
curl http://{webservice}/rest/functions/{Id}?sid={sid} -X DELETE
Status: 204 No Content