If you want to execute a Cloud Function from code, you need to make an HTTP request to its specific endpoint URL. This URL is generated like this:
- app-id—the App ID of your app
- function-name—the name of the cloud function you want to execute
- parameter1=value1¶meter2=value2&...parameterN=valueN—optional URL parameters passed to the cloud function
When making the HTTP request, you can use any HTTP method you need—GET, POST, DELETE, and so on. The result will be the same unless your Cloud Function implements branching depending on the HTTP method.
With the HTTP request, you can include any headers that you need. The headers, along with the HTTP request body, are available to your Cloud Function during execution and are a handy way to send parameters. Do not forget to set the Content-Type header properly if you are using the request body to send data. Accessing URL parameters and header data is described in Defining Cloud Functions.