- Stitch >
- External Services >
- Work With Services
Call a Service Action¶
Overview¶
You can call actions associated with a service from Stitch functions, including incoming webhooks and triggers, or directly from a connected client application. Each service action is available as a method on its respective service client.
Note
You must define a service rule that enables an action before you can call it.
Usage¶
The examples in this section demonstrate calling the post() action from the HTTP Service. Each service action follows a similar pattern but has distinct parameters. For details on the parameters and usage of a specific action, refer to that action’s reference page.
Call from Another Function¶
To call a service action from a function:
- Instantiate a service client from application
context using the
context.services
global variable. - Call the method associated with the action.
Call from a Client Application¶
- JavaScript SDK
- Android SDK
- iOS SDK
You can call a service action from client applications that are connected with a Client SDK or over the wire protocol.
To call a service action from a JavaScript Client SDK:
Ensure that you have installed or included the SDK service package for the service you wish to call an action on. You can pull in the service package from a CDN or install it with
npm
.Import the service client object and any necessary service request objects.
Note
Request objects, such as the
HTTPMethod
object in this example, are helpers that some services use to construct requests in Client SDKs.Instantiate a service client with the getServiceClient() method.
Create and call a request
To call a service action from the Android Client SDK:
Ensure that you have installed the SDK service package for the service you wish to call an action on.
Import the service client object and any necessary service request objects.
Note
Request objects, such as the
HTTPMethod
object in this example, are helpers that some services use to construct requests in Client SDKs.Instantiate a service client with the getServiceClient() method.
Create and call a request
To call a service action from the iOS Client SDK:
Ensure that you have installed the SDK service Pod for the service you wish to call an action on.
Import the service client object and any necessary service request objects.
Note
Request objects, such as the
HTTPMethod
object in this example, are helpers that some services use to construct requests in Client SDKs.Instantiate a service client with the serviceClient(fromFactory:withName:) method.
Create and call a request