2017-09-23 81 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

它工作!謝謝。 –

相關問題