我正在尝试将 Google 脚本连接到 IronWorker 脚本。
现在,我只是想让一个“你好,世界”级别的例子起作用。
我的最终目标是将数据从 Google 电子表格传递给 IronWorker 进行处理。
现在,我只想成功发布到 IronWorker。这是谷歌脚本功能:
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 版,我确实看到了这个 StackOverflow 问题:IronWorkers 何时支持 Ruby 2.0?
我不确定它是否相关,但错误输出表明这是一个红宝石问题。
任何想法将不胜感激,谢谢!