2017-10-13 7 views
0
var xhr = new XMLHttpRequest(); 
xhr.responseType = 'String'; 
xhr.onreadystatechange = function() { 
    if (xhr.readyState === 4 && xhr.status === 200) { 
    var response = xhr.response; 
    console.log(response); 
    } 
}; 
xhr.open('POST', 'https://api.dropboxapi.com/2/files/list_folder'); 
xhr.setRequestHeader('Authorization', 'Bearer ' + token); 
xhr.setRequestHeader('Content-Type', 'application/json'); 
xhr.setRequestHeader('Dropbox-API-Arg', JSON.stringify({ 
    path: '/lol' 
})); 
xhr.send(); 

コードで何が間違っているかわかりません。どんな助け? list_folderのドキュメントを見てみるとDropbox list_folder api javascriptが機能しない

+0

正確に動作しないものはありますか?あなたはどんな反応を得ますか? – Greg

答えて

0

- エンドポイントは、RPCエンドポイントであること:

これらのエンドポイントは、リクエストボディにJSONなどの引数を受け入れ、レスポンスボディにJSONとして結果を返します。 RPCエンドポイントはapi.dropboxapi.comドメインにあります。

Dropbox-API-Argヘッダは、私が/files/list_folderエンドポイントのために必要Dropbox-API-Argと呼ばれるヘッダについては何も表示されない

Content-uploadContent-downloadタイプのエンドポイントのために使われているようです。試してみてください

xhr.open('POST', 'https://api.dropboxapi.com/2/files/list_folder'); 
xhr.setRequestHeader('Authorization', 'Bearer ' + token); 
xhr.setRequestHeader('Content-Type', 'application/json'); 
xhr.send(JSON.stringify({path:"/lol"})); 
関連する問題