如何在 Google 人 API 获取请求中设置 'personFields' 查询参数?
How can i set 'personFields' query parameter in Google People API get request?
var xhttp = new XMLHttpRequest();
var theUrl = "https://people.googleapis.com/v1/people/c3591871730916654475?personFields='names,photos,coverPhotos'";
xhttp.open("GET", theUrl, true);
xhttp.setRequestHeader('Authorization', 'Bearer ' + currentSessionAccessToken)
xhttp.onload = function(){
if(xhttp.status == 200){
var profileJson = JSON.parse(xhttp.response);
resolve(profileJson);
}
else{
if(xhttp.status == 404){
resolve('No_RESULT_FOUND');
}
else{
reject(xhttp.statusText);
}
}
};
xhttp.onerror = function(){
reject(xhttp.statusText);
};
xhttp.send();
以上是我的 XMLHttpRequest。请求后我收到以下错误:
"{
"error":{
"code": 400,
"message": "Invalid personFields mask path: \"\"names\"。有效路径记录在 https://developers.google.com/people/api/rest/v1/people/get 中。",
"status": "INVALID_ARGUMENT"
}
}
“
有人能给我推荐一条有效的路径吗?我没有在文档中找到。
将 personFields='names,photos,coverPhotos'
改为 personFields=names,photos,coverPhotos
,去掉 '
。
var xhttp = new XMLHttpRequest();
var theUrl = "https://people.googleapis.com/v1/people/c3591871730916654475?personFields='names,photos,coverPhotos'";
xhttp.open("GET", theUrl, true);
xhttp.setRequestHeader('Authorization', 'Bearer ' + currentSessionAccessToken)
xhttp.onload = function(){
if(xhttp.status == 200){
var profileJson = JSON.parse(xhttp.response);
resolve(profileJson);
}
else{
if(xhttp.status == 404){
resolve('No_RESULT_FOUND');
}
else{
reject(xhttp.statusText);
}
}
};
xhttp.onerror = function(){
reject(xhttp.statusText);
};
xhttp.send();
以上是我的 XMLHttpRequest。请求后我收到以下错误:
"{ "error":{ "code": 400, "message": "Invalid personFields mask path: \"\"names\"。有效路径记录在 https://developers.google.com/people/api/rest/v1/people/get 中。", "status": "INVALID_ARGUMENT" } } “
有人能给我推荐一条有效的路径吗?我没有在文档中找到。
将 personFields='names,photos,coverPhotos'
改为 personFields=names,photos,coverPhotos
,去掉 '
。