0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Workato:レシピをJSONで取得するには

Last updated at Posted at 2021-09-28

はじめに

Workatoのレシピのメンテナンスを行う際、過去のバージョンのレシピやコピーしたレシピと差分比較したくなる場合がありますが、残念ながらWorkatoには現時点(2021/9/28)において差分比較(diff)を行う機能がありません。(以前はWorkato XというChrome機能拡張で差分比較を行うことができましたが、機能拡張がWorkatoのアップデートに対応できておらず、現在は利用することが出来ません)

しかし、幸いなことにWorkatoのレシピは、レシピエディタの画面生成時に参照されるURLよりJSONで取得することが可能です。このJSONを利用することで、過去バージョンのレシピやコピーしたレシピとの差分比較が可能となります。今回は、その手順について下記します。

手順

1.Workatoへログインした状態で、Chrome等のDeveloper ToolのConsoleで以下のコードを実行します。

let result = {};
const recipeId = <レシピID>;
const version = <レシピバージョン>;

fetch('https://app.workato.com/recipes/' + recipeId + '/code.json?version_no=' + version)
        .then(res => res.json())
        .then(obj => JSON.parse(obj.result))
        .then(obj => {console.log(obj)});

※全バージョンを一気に取得したい場合

レシピの全バージョンを一気に取得したい場合は、次の通りとします。

let result = [];
const recipeId = <レシピID>;
const maxVersion = <レシピ最新バージョン>;
for (let i = 1; i <= maxVersion; i++) {
    fetch('https://app.workato.com/recipes/' + recipeId + '/code.json?version_no=' + i)
        .then(res => res.json())
        .then(obj => JSON.parse(obj.result))
        .then(obj => result.push({version: i, result: obj}));
}

上記実行後、以下のコードを実行します。

console.log(result);

2.出力結果を右クリックし「Copy object」をクリックすると、JSONでレシピを取得できます。

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?