Running regular action/web action
    • PDF

    Running regular action/web action

    • PDF

    Article Summary

    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?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.