【发布时间】:2015-03-27 12:07:35
【问题描述】:
我正在尝试将产品列表的数据从 Magento API 传递到 Google 电子表格。 Magento API 不需要身份验证,因为我以访客身份检索数据。 API 与 RestClient 完美配合。
但是,从 Googe Apps 脚本获取 REST 资源时出现 500 错误。
Exception: Request failed for
http://mymagentohost/api/rest/products?limit=2
returned code 500. Truncated server response: Service temporary
unavailable (use muteHttpExceptions option to examine full response)
这是我的 Google Apps 脚本:
function myscript() {
var url = "http://mymagentohost/api/rest/products?limit=2"
var response = UrlFetchApp.fetch(url);
var out = JSON.parse(response.getContentText());
var doc = SpreadsheetApp.create("Product Info");
var cell = doc.getRange('a1');
var index = 0;
for (var i in out) {
var value = out[i];
cell.offset(index, 0).setValue(i);
cell.offset(index, 1).setValue(value);
index++;
}
有什么想法吗?
【问题讨论】:
-
ATM 在这里不工作,使用hurl.it。
-
谢谢,但我想让它与 Google Apps 脚本一起使用。
-
我知道,但要让它与 ApsScript 一起工作,我必须让它在一个专门的 curl 站点上工作,我总是使用那个。如果地址“mymagentohost/api/rest/products?limit=2”有效,您是否检查过任何其他 Curl 站点?此外,谷歌不喜欢不安全的 http 链接。
-
我检查过,它在 hurl.it 中有效!
标签: api rest magento google-apps-script