Running regular action/web action
- Print
- PDF
Running regular action/web action
- Print
- PDF
Article Summary
Share feedback
Thanks for sharing your feedback!
Available in Classic and VPC
Execution examples of regular actions (triggers) and web actions in various runtime environments. We can understand regular actions (triggers) and web actions more efficiently through comparing execution examples of each.
Node.js
The following are some examples of using Node.js.
- Regular action, trigger
// npm install axios const axios = require('axios'); var config = { headers: { 'Content-Type': 'application/json', } }; axios.post( '{ActionURL}?blocking=true&result=true' , {} , config) .then(response => { console.log(response.data); }) .catch(error => { console.log(error); });
- Web action
// npm install axios const axios = require('axios'); var config = { headers: { 'Content-Type': 'application/json', } }; axios.get('{ActionURL}?blocking=true&result=true', config) .then(response => { console.log(response.data); }) .catch(error => { console.log(error); });
Spring Code
The following are some examples of using Spring code.
- Regular action, trigger
Map<String, String> params = new HashMap<>(); HttpHeaders header = new HttpHeaders(); header.add(HttpHeaders.CONTENT_TYPE, "application/json"); HttpEntity<Map> requestEntity = new HttpEntity<>(params, header); ResponseEntity<Map> response = restTemplate .exchange("{ActionURL}?blocking=true&result=true" , HttpMethod.POST, requestEntity, Map.class);
- Web action
HttpHeaders header = new HttpHeaders(); header.add(HttpHeaders.CONTENT_TYPE, "application/json"); HttpEntity<Map> requestEntity = new HttpEntity<>(header); ResponseEntity<Map> response = restTemplate.exchange("{ActionURL}?blocking=true&result=true", HttpMethod.GET, requestEntity, Map.class);
Go Code
The following are some examples of using Go code.
- Regular action, trigger
package main import ( "fmt" "io/ioutil" "net/http" "bytes" ) func main() { var params = []byte(`{}`) req, err := http.NewRequest("POST", "{ActionURL}?blocking=true&result=true", bytes.NewBuffer(params)) if err != nil { panic(err) } req.Header.Add("Content-Type", "application/json") client := &http.Client{} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close() bytes, _ := ioutil.ReadAll(resp.Body) str := string(bytes) fmt.Println(str) }
- Web action
package main import ( "fmt" "io/ioutil" "net/http" ) func main() { req, err := http.NewRequest("GET", "{ActionURL}?blocking=true&result=true", nil) if err != nil { panic(err) } req.Header.Add("Content-Type", "application/json") client := &http.Client{} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close() bytes, _ := ioutil.ReadAll(resp.Body) str := string(bytes) fmt.Println(str) }
Was this article helpful?