Exago Logo
Search
Generic filters
Exact matches only

REST – Functions

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 a Session ID URL parameter and basic request headers. In the following document, headers are omitted in the interest of brevity.

Function JSON

Functions are represented as JSON objects with the following properties:

NameTypeWriteableDescription
Idstringrequired-createThe unique Id of this function
DescriptionstringyesThe description of this function
MinArgsintegerno(Deprecated in v2017.2)
Minimum number of arguments for this function
MaxArgsintegerno(Deprecated in v2017.2)
Maximum number of arguments for this function
LanguageenumyesCode Language
Namespacesarray of stringsyesNamespaces for this function
Referencesarray of stringsyesReferences for this function
ProgramCodestringyesFunction code
IsCustombooleannoWhether this is a custom function

Example

{
  "Id":          "DayOfWeek",
  "Description": "Returns the day of the week as a string given a date value",
  "MinArgs":     null,
  "MaxArgs":     null,
  "Language":    "cs",
  "Namespaces":  [],
  "References":  ["System.dll"],
  "ProgramCode": "return System.Convert.ToDateTime(args[0].ToString());",
  "IsCustom":    true
}

List Functions

GET /rest/Functions

List all the functions in the current configuration. Output is an array of objects, each representing an individual function.

NameTypeDescription
IdstringThe unique Id of this function

Available parameters

NameTypeDescription
filterstringPossible values: custom – Return only custom functions.

Using curl

curl http://{webservice}/rest/Functions?sid={sid} -X GET

Example response

Status: 200 OK

[
  {
    "Id": "Today"
  },
  {
    "Id": "Tomorrow"
  },
  ...
]

Show Function

GET /rest/Functions/{Id}

Show the properties of the function specified by its Id.

Using curl

curl http://{webservice}/rest/Functions/{Id}?sid={sid} -X GET

Example response

Status: 200 OK

{
  "Id":          "Today",
  "Description": "",
  "MinArgs":     null,
  "MaxArgs":     null,
  "Language":    "cs",
  "Namespaces":  [],
  "References":  [],
  "ProgramCode": "return sessionInfo.Today;",
  "IsCustom":    true
}

Create Function

POST /rest/Functions

Using curl

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','References':['System.dll'],'ProgramCode':'return System.Convert.ToDateTime(args[0].ToString());'}"

Example response

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":     null,
  "MaxArgs":     null,
  "Language":    "cs",
  "Namespaces":  [],
  "References":  ["System.dll"],
  "ProgramCode": "return System.Convert.ToDateTime(args[0].ToString());",
  "IsCustom":    true
}

Edit Function

PATCH /rest/Functions/{Id}

Only supply the properties to be edited. Only custom functions can be edited.

Using curl

curl http://{webservice}/rest/Functions/{Id}?sid={sid} -X PATCH ^
	-d "{'Namespaces':['WebReports.Api']}"

Example response

Status: 204 No Content

Delete Function

DELETE /rest/Functions/{Id}

Only custom functions can be deleted.

Using curl

curl http://{webservice}/rest/Functions/{Id}?sid={sid} -X DELETE

Example response

Status: 204 No Content
Was this article helpful?
0 out of 5 stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.
Table of Contents