以下对MongoLab数据库的REST API查询在浏览器中正常工作:
var url = https://api.mongolab.com/api/1/databases/sis/collections/my-coll?q= {%22Object%20Type%22:%22Object%20Types%22}& apiKey =
但是,当我使用Google appscript的UrlFetchApp时,如下所示:
var oDataObject = JSON.parse(UrlFetchApp.fetch(url).getContentText());
..然后appscript返回以下错误:
无效参数:https://api.mongolab.com/api/1/databases/my-db/collections/my-coll?q=
有人知道如何解决Google appscript UrlFetchApp中的这个怪癖吗?
答案 0 :(得分:0)
var sQuery = encodeURIComponent(JSON.stringify(oQuery));
var sUrl = 'https://api.mongolab.com/api/1/databases/'
+ MWO_GetDbName() +'/collections/my- coll?'
+ 'q=' + sQuery + '&apiKey=' + MWO_GetDbKey();
var oDataObject = JSON.parse(UrlFetchApp.fetch(sUrl).getContentText());
return oDataObject;