1

Topic: Dropbox v2. Directory reading

I try to read resource Dropbox, using API Dropbox v2.
I try as in an example: https://www.ibm.com/developerworks/comm … Dropbox...
[spoiler]

private static final String APP_KEY = "ly2h44xro59e4sg";
private static final String APP_SECRET = "krcj1lmdzpzm4sl";
private static final String token = "EKpeC3qgzRAAAAAAAAAAE5K0YPRWz2OyELi-H1TgKfD9z_Jnw7rgKc-RQ9pBT9n9";
mDbxAcctMgr = DbxAccountManager.getInstance (getApplicationContext (), APP_KEY, APP_SECRET);
listFolder ("");
public void listFolder (String foldername) throws Exception {
try {
URL url = new URL ("https://api.dropboxapi.com/2/files/list_folder");
HttpURLConnection conn = (HttpURLConnection) url.openConnection ();
String parameters = "{\" path \": \" "+ foldername +" \", \" recursive \": false, \" include_media_info \": false, \" include_deleted \": false, \" include_has_explicit_shared_members \": false}";
conn.setRequestProperty ("Accept", "application/json");
conn.addRequestProperty ("Authorization", token);
conn.setRequestMethod ("POST");
conn.setRequestProperty ("Content-Type", "application/json");
conn.setDoOutput (true);
DataOutputStream writer = new DataOutputStream (conn.getOutputStream ());
writer.writeBytes (parameters);
writer.flush ();
if (writer! = null)
writer.close ();
if (conn.getResponseCode ()! = 200) {
System.out.println (conn.getResponseMessage ());
throw new RuntimeException ("Failed: HTTP error code:"
+ conn.getResponseCode ());
}
BufferedReader br = new BufferedReader (new InputStreamReader (
(conn.getInputStream ())));
String output;
System.out.println ("Output from Server.... \n");
while ((output = br.readLine ())! = null) {
System.out.println (output);
}
conn.disconnect ();
} catch (MalformedURLException e) {
e.printStackTrace ();
} catch (IOException e) {
e.printStackTrace ();
}
}

[/spoiler]
But this line I receive IOException at performance "conn.getOutputStream ()":

DataOutputStream writer = new DataOutputStream (conn.getOutputStream ());

What can be not so?

2

Re: Dropbox v2. Directory reading

P.S. A correct reference: https://www.ibm.com/developerworks/comm … le?lang=en

3

Re: Dropbox v2. Directory reading

Slon747 wrote:

But this line I receive IOException at performance "conn.getOutputStream ()":

On good full a broad gull of an error with a stack...

4

Re: Dropbox v2. Directory reading

Here there is an example just for  https://github.com/dropbox/dropbox-sdk- … es/android

5

Re: Dropbox v2. Directory reading

wadman wrote:

it is passed...
On good full a broad gull of an error with a stack...

And how to me it to make?
After all DataOutputStream demands to turn in handling try-catch.

6

Re: Dropbox v2. Directory reading

Slon747 wrote:

And how me it to make?

In studio about debugging  all is deduced, including and with errors.

7

Re: Dropbox v2. Directory reading

8

Re: Dropbox v2. Directory reading

Slon747 wrote:

Perhaps all the matter is that needs to be fulfilled in an asynchronous mode?

for a long time already cuts all network operations in a principal flow...
Therefore I also gave an example for .