EDUCAÇÃO E TECNOLOGIA

Cheat sheet for URI patterns for calling OData actions and functions

When developing CAP services, I often stumble upon testing actions and functions, because URI patterns vary depending on action / function, if it is bound or unbound, and OData version. That’s why I decided to write this short blog post for my reference. I hope this also helps someone else.

To test the examples below, clone the following GitHub repository and run cds watch.
https://github.com/miyasuta/actions-and-functions

To learn more about CAP actions and functions, and what are bound / unbound actions / functions, please find the document below.
https://cap.cloud.sap/docs/cds/cdl#actions

Actions

General patterns

  • Bound Action: pathToService/EntitySet(key)/ServiceName.actionName
  • Unbound Action: pathToService/actionName

Examples

Functions

General patterns

Parenthesis() are required after function names.

  • Bound function: pathToService/EntitySet(key)/ServiceName.functionName(paramName1=<value>,paramName2=<value>)
  • Unbound function: pathToService/functionName(paramName1=<value>,paramName2=<value>)

Examples

Actions

General patterns

Two URI patterns are accepted for bound actions. Pattern1 is the same as v4, and pattern2 is specific to v2.

  • Bound Action (pattern1): pathToService/EntitySet(key)/ServiceName.actionName
  • Bound Action (pattern2): pathToService/EntitySet_actionName?key=<value>
  • Unbound Action: pathToService/actionName

Examples

Functions

General patterns

OData V2 functions work with or without parenthesis() after function names.

  • Bound function: pathToService/EntitySet_functionName?key=<value>&paramName1=<value>&paramName2=<value>
  • Unbound function: pathToService/functionName?paramName1=<value>&paramName2=<value>

Examples