Execute a Function

You can execute a Catalyst functions in any one of the ways given below, based on the HTTP request you pass with the function. You can pass the parameters to the function to be executed as the argument to a function execution method. This method differs for each HTTP request type.

Note: You can create four types of functions in Catalyst: Basic I/O, Advanced I/O, Cron, and Event functions. However, you can only execute Basic I/O functions in Catalyst Android SDK.

The <FUNCTION_INSTANCE> used in all the code sections below is the instance defined in the Function Instance page .

Execute a GET function

You can execute a function of the HTTP GET type, by passing the parameters to the executeGet() method as a Hash map:

    
copy
<FUNCTION_INSTANCE>.executeGet( params: HashMap<String, Any>, success: (String) → Unit, failure: ((ZCatalystException) → Unit)? ): ZCatalystRequest<String>?

Parameters:

  • params: The parameters to be passed to the function as a Hash map

A sample code snippet is shown below:

    
copy
ZCatalystApp.getInstance().getFunctionInstance(2823000000097020).executeGet( //Replace this with your Function ID hashMapOf(), { println(">> GET function executed successfully - $it") }, { println(">> GET function failed to execute - $it") } )

Execute a PUT function

You can execute a function of the HTTP PUT type, by passing the parameters to the executePut() method as a Hash map. You can pass the payload in the PUT request to this method as a Hash map argument as well:

    
copy
<FUNCTION_INSTANCE>.executePut( params: HashMap<String, Any>, body: HashMap<String, Any>, success: (String) → Unit, failure: ((ZCatalystException) → Unit)? ): ZCatalystRequest<String>?

Parameters:

  • params: The parameters to be passed to the function as a Hash map
  • body: The data payload to be passed as a Hash map

A sample code snippet is shown below:

    
copy
val body = HashMap<String, Any>() body.put("ROWID", "2823000000098012") body.put("Category", "Important") //Add your keys and values to a hash map ZCatalystApp.getInstance().getFunctionInstance(2823000000097114).executePut( //Replace this with your Function ID hashMapOf(), body, { println(" >> PUT function executed successfully - $it") }, { println(" >> PUT function failed to execute - $it") } )

Execute a POST function

You can execute a function of the HTTP POST type, by passing the parameters to the executePOST() method as a Hash map. You can pass the payload in the POST request to this method as a Hash map argument as well:

    
copy
<FUNCTION_INSTANCE>.executePost( params: HashMap<String, Any> , body: HashMap<String, Any> , success: (String) → Unit, failure: ((ZCatalystException) → Unit)? ): ZCatalystRequest<String>?

Parameters:

  • params: The parameters to be passed to the function as a Hash map
  • body: The data payload to be passed as a Hash map

A sample code snippet is shown below:

    
copy
val body = HashMap<String, Any>() body.put("Title", "Data Migration Tasks") body.put("Category", "Official") //Add your keys and values to a hash map ZCatalystApp.getInstance().getFunctionInstance(2823000000097089).executePost( //Replace this with your Function ID hashMapOf(), body, { println(" >> POST function executed successfully - $it") }, { println(" >> POST function failed to execute - $it") } )