(JavaScript) Dropbox: Get Space Usage
Demonstrates how to get the Dropbox space usage information for the current user's account. For more information, see https://www.dropbox.com/developers/documentation/http/documentation#users-get_space_usage
var success = false;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
var rest = new CkRest();
// Connect to the www.dropbox.com endpoint.
var bTls = true;
var port = 443;
var bAutoReconnect = true;
success = rest.Connect("api.dropboxapi.com",port,bTls,bAutoReconnect);
if (success !== true) {
console.log(rest.LastErrorText);
return;
}
rest.AddHeader("Authorization","Bearer DROPBOX-ACCESS-TOKEN");
var responseStr = rest.FullRequestNoBody("POST","/2/users/get_space_usage");
if (rest.LastMethodSuccess !== true) {
console.log(rest.LastErrorText);
return;
}
// Success is indicated by a 200 response status code.
if (rest.ResponseStatusCode !== 200) {
// Examine the request/response to see what happened.
console.log("response status code = " + rest.ResponseStatusCode);
console.log("response status text = " + rest.ResponseStatusText);
console.log("response header: " + rest.ResponseHeader);
console.log("response body (if any): " + responseStr);
console.log("---");
console.log("LastRequestStartLine: " + rest.LastRequestStartLine);
console.log("LastRequestHeader: " + rest.LastRequestHeader);
return;
}
var jsonResponse = new CkJsonObject();
jsonResponse.Load(responseStr);
jsonResponse.EmitCompact = false;
console.log(jsonResponse.Emit());
// {
// "used": 3032115,
// "allocation": {
// ".tag": "individual",
// "allocated": 2147483648
// }
// }
//
|