从 Google 脚本向 IronWorker 发送 UrlFetchApp(url, options) 请求
Send UrlFetchApp(url, options) request from Google Script to IronWorker
我正在尝试将 Google 脚本连接到 IronWorker 脚本。
现在,我只是想让一个 "hello, world" 级别的例子起作用。
我的最终目标是将数据从 Google 电子表格传递到 IronWorker 进行处理。
现在,我只想成功POST一个IronWorker。这是 Google 脚本函数:
function myFunction() {
var arr = { "first" : "Chris", "last" : "Cruz" };
var url = 'https://worker-aws-us-east1.iron.io/2/projects/55c4f983e68185000600002b/tasks/webhook?code_name=hello-world-worker%3A%3Abuilder&oauth=mpPgu7iB0rT80iQ0mpCnCcy3nYE';
var options =
{
"method" : "post",
"data" : JSON.stringify(arr)
}
var response = UrlFetchApp.fetch(url, options);
Logger.log(response);
}
当我检查 'Hello, world»Workers»hello-world-worker::builder»Task #...10b44»Log' 中的日志时,我看到了这个错误输出:
Successfully installed net-http-persistent-2.9.4
Successfully installed netrc-0.10.3
Successfully installed rest-3.0.6
Successfully installed iron_core-1.0.9
Successfully installed bundler-1.10.6
Successfully installed rubyzip-1.1.7
Successfully installed iron_worker_ng-1.6.6
7 gems installed
/usr/lib/ruby/1.9.1/json/common.rb:148:in `initialize': can't convert nil into String (TypeError)
from /usr/lib/ruby/1.9.1/json/common.rb:148:in `new'
from /usr/lib/ruby/1.9.1/json/common.rb:148:in `parse'
from /mnt/task/__builder__.rb:47:in `<top (required)>'
from /usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from __runner__.rb:224:in `<main>'
我不确定错误是从哪里调用的,所以我不知道从哪里开始调试。我是 运行 ruby 2.0 版,我确实看到了这个 Whosebug 问题:When will IronWorkers support Ruby 2.0?
我不确定它是否相关,但错误输出表明这是一个 ruby 问题。
任何想法将不胜感激,谢谢!
后缀为 ::builder
的工人是 "special"。他们为您远程(在 IronWorker 上)构建工人代码包。当您将 remote
指令放入 .worker
文件时,就会发生这种情况。实际工作人员姓名为 hello-world-worker
。因此,您的 webhook URL 必须如下所示:
'https://worker-aws-us-east1.iron.io/2/projects/55c4f983e68185000600002b/tasks/webhook?code_name=hello-world-worker&oauth=<TOKEN>'
将 <TOKEN>
替换为您的实际令牌。当您共享当前令牌时,我建议您将其删除并生成新令牌。您可以通过单击 HUD 右上角的您的名字,然后单击 "My Tokens" 菜单项来完成此操作。
我正在尝试将 Google 脚本连接到 IronWorker 脚本。
现在,我只是想让一个 "hello, world" 级别的例子起作用。
我的最终目标是将数据从 Google 电子表格传递到 IronWorker 进行处理。
现在,我只想成功POST一个IronWorker。这是 Google 脚本函数:
function myFunction() {
var arr = { "first" : "Chris", "last" : "Cruz" };
var url = 'https://worker-aws-us-east1.iron.io/2/projects/55c4f983e68185000600002b/tasks/webhook?code_name=hello-world-worker%3A%3Abuilder&oauth=mpPgu7iB0rT80iQ0mpCnCcy3nYE';
var options =
{
"method" : "post",
"data" : JSON.stringify(arr)
}
var response = UrlFetchApp.fetch(url, options);
Logger.log(response);
}
当我检查 'Hello, world»Workers»hello-world-worker::builder»Task #...10b44»Log' 中的日志时,我看到了这个错误输出:
Successfully installed net-http-persistent-2.9.4
Successfully installed netrc-0.10.3
Successfully installed rest-3.0.6
Successfully installed iron_core-1.0.9
Successfully installed bundler-1.10.6
Successfully installed rubyzip-1.1.7
Successfully installed iron_worker_ng-1.6.6
7 gems installed
/usr/lib/ruby/1.9.1/json/common.rb:148:in `initialize': can't convert nil into String (TypeError)
from /usr/lib/ruby/1.9.1/json/common.rb:148:in `new'
from /usr/lib/ruby/1.9.1/json/common.rb:148:in `parse'
from /mnt/task/__builder__.rb:47:in `<top (required)>'
from /usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from __runner__.rb:224:in `<main>'
我不确定错误是从哪里调用的,所以我不知道从哪里开始调试。我是 运行 ruby 2.0 版,我确实看到了这个 Whosebug 问题:When will IronWorkers support Ruby 2.0?
我不确定它是否相关,但错误输出表明这是一个 ruby 问题。
任何想法将不胜感激,谢谢!
后缀为 ::builder
的工人是 "special"。他们为您远程(在 IronWorker 上)构建工人代码包。当您将 remote
指令放入 .worker
文件时,就会发生这种情况。实际工作人员姓名为 hello-world-worker
。因此,您的 webhook URL 必须如下所示:
'https://worker-aws-us-east1.iron.io/2/projects/55c4f983e68185000600002b/tasks/webhook?code_name=hello-world-worker&oauth=<TOKEN>'
将 <TOKEN>
替换为您的实际令牌。当您共享当前令牌时,我建议您将其删除并生成新令牌。您可以通过单击 HUD 右上角的您的名字,然后单击 "My Tokens" 菜单项来完成此操作。