use*_*253 3 javascript api google-apps-script
我正在尝试从rainforestqa API获取数据,但为了获得访问权限,我需要将我的api_key作为标题发送.我已经拥有的代码如下,
var header = {
"access-control-allow-headers":"Content-Type",
"CLIENT_TOKEN" : "API-TOKEN"
};
var options = {
"method" : "post",
"header" : header
};
UrlFetchApp.fetch("https://app.rainforestqa.com:443/api/1/runs/TESTNUMBER/tests.json?result=failed", options);
Run Code Online (Sandbox Code Playgroud)
但是这会返回405错误.有没有人有任何想法为什么这不起作用?
谢谢
事实证明答案如下,我基本上通过反复试验来解决这个问题.
$var options = {
"async": true,
"crossDomain": true,
"method" : "GET",
"headers" : {
"CLIENT_TOKEN" : "my-api-key",
"cache-control": "no-cache"
}
};
var response = UrlFetchApp.fetch("https://app.rainforestqa.com:443/api/1/runs/test_id/tests.json?result=failed", options);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5767 次 |
| 最近记录: |