2017-09-23 75 views
0
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。请求后我得到下面的错误:如何在Google People API获取请求中设置'personFields'查询参数?

“{ ”错误“:{ ”代码“:400, ”消息“: ”无效personFields掩模路径:\“ \” 名称\”有效路径是在https://developers.google.com/people/api/rest/v1/people/get记录 “ ”状态“: ”?INVALID_ARGUMENT“ } } ”

能否有人建议我一个有效的路径,我没有对文档中找到

回答

1

变化personFields='names,photos,coverPhotos'personFields=names,photos,coverPhotos没有。 '

+0

它工作!谢谢。 –

相关问题