ForumsThird-Party ApplicationsAndroid API v3 - how to make a folder


Android API v3 - how to make a folder
Author Message
jj974

Posted: Nov 30, 2014
Score: 0 Reference
Getting connected from an Android app to Toodledo API v3 works.
So, I know that I have a valid access_token (and refresh token).
GET requests work.

How can I add a folder ... using a POST request?

The code is below ... it keeps on spinning for new access tokens.

HttpResponse response = null;
JSONObject folderJS;
try {
Credential cred = flow.loadCredential( userId);
cred.setAccessToken( accessToken);
cred.setExpirationTimeMilliseconds( accessTokenExpireTime);
cred.setRefreshToken( refreshToken);
String apiCallUrl = "https://api.toodledo.com/3/folders/add.php";

GenericData data = new GenericData();
data.put( "name", folderName);
data.put( "private", "1");
// data.put( "access_token", accessToken); <== is not needed ?

JsonHttpContent httpContent = new JsonHttpContent(new JacksonFactory(), data);
response = HTTP_TRANSPORT.createRequestFactory( cred).buildPostRequest(
new GenericUrl( apiCallUrl), httpContent).execute();
jj974

Posted: Dec 01, 2014
Score: 0 Reference
Moving 1 step forward ... but getting a very strange result:

I now found a different way of passing the HttpContent

Map<String, String> params2 = new HashMap<String, String>(3);
params2.put("name", folderName);
params2.put("private", "1");
params2.put("access_token", accessToken);
HttpContent httpContent = new UrlEncodedContent( params2);

When I now execute the request, it will LOOP (!) on storing an access token to my credential store. Why? It just used the access_token to list the folders. No problem.
You cannot reply yet

U Back to topic home

R Post a reply

To participate in these forums, you must be signed in.