一般アクション/ウェブアクションの実行
    • PDF

    一般アクション/ウェブアクションの実行

    • PDF

    Article Summary

    Classic/VPC環境で利用できます。

    様々なランタイム環境で一般的なアクション(トリガー)とウェブアクションの実行例を紹介します。 それぞれの実行例を比べると、一般アクション(トリガー)とウェブアクションをより効果的に理解できます。

    Node.js

    Node.jsを利用した実行例は以下のとおりです。

    • 一般アクション、トリガー
      // 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);
        });
      
    • ウェブアクション
      // 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

    Springコードを利用して実行した例は以下のとおりです。

    • 一般アクション、トリガー
      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);
      
    • ウェブアクション
      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

    Goコードを利用して実行した例は以下のとおりです。

    • 一般アクション、トリガー
      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)
      }
      
    • ウェブアクション
      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)
      }
      

    この記事は役に立ちましたか?

    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.