Issuing REST Requests from Within Cloud Actions
Within a Cloud Action you have the option to invoke REST endpoints of external, third-party REST APIs using Octave's http
methods such as Octave.Http.get(). This topic provides a simple example showing how to invoke this method in a Cloud Action.
The steps below example illustrate how to set up a Cloud Action to invoke a REST GET request:
- Create a Cloud Action and set Source stream or tag to Stream.
- Enter the following code into the Cloud Action and modify it as required. Here,
Octave.Http.get
passed the URL of an hypothetical endpoint to invoke a GET request on, along with a JSON object (options
) containing the header values to include:
function(event) {
var options = { "X_API_KEY": "AN API KEY", "OTHER_HEADER": "OTHER HEADER VALUE" };
// With a GET method
var resultGet = Octave.Http.get("http://myprivateapi.com/endpoint", options);
// Your code here
return {}
}
- Click Save.
Note:
For additional APIs see: Cloud JavaScript Library.
Updated over 4 years ago