node.js - 在 Google SearchAnalytics API 中发出 POST 请求时出现 404 错误
问题描述
我正在尝试发出 POST 请求以从 Google SearchAnalytics API 获取 SearchAnalytics 数据。
我正在从网站管理员 API 资源管理器工具中获取数据。但是当我从 Node js 发出相同的请求时,我收到 404 错误。
以下是我尝试过的:
request.post({
headers: {
'content-type' : 'application/json',
'Authorization' : 'Bearer '+access_token
},
url: siteURL,
json : {
'startDate':'2018-06-01',
'endDate':'2018-06-22'
}
},
function(error, response, body)
{
console.log('Error - '+error);
console.log('Response - '+JSON.stringify(response));
console.log('Body - '+body);
res.end();
});
来自谷歌的回应:
{"statusCode":404,"body":"Not Found",....}
解决方案
经过几个小时的挣扎,终于发现问题出在我的siteURL
变量上。
以前的网址无效
var siteURL = 'https://example.com'
工作网址
var siteURL = 'https%3A%2F%2Fexample.com'
推荐阅读
- android - 如何使用 Facebook SDK 以编程方式跟踪给定用户 ID 的应用安装源?
- android - React-Native 选项卡导航栏被切断
- laravel - 无法通过 Laravel 插入多个 INSERT 查询
- regex - 从正则表达式中删除不需要的匹配项
- r - 基于 R 中先前值组合的递归值
- javascript - 找不到模块'@schemics/angular/utility/project'
- firebase - Google Analytics 用户活动显示错误的事件参数
- apache-spark - 如何检查火花中的路径存在?
- sql - 从带有条件的表中查找 MAX id
- c# - 如何使用 cicd 更新应用程序版本?(点击一次)