ForumsSearch



Search results for "Posted by mikayla"
Author Message
mikayla

Score: 0
  • mikayla
  • Posted: Dec 09, 2014
  • Score: 0
So I think I figured out what the issue is. I can get this to work if I only send 1 or 2 tasks, but when I send all 9 tasks I get a malformed error.

This goes against what it says in your documentation for tasks where it says "You can add up to 50 tasks at a time". I can't even add 10.

My best guess is that this has something to do with url lengths being limited?

See: http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers

But now that I have it working /sometimes/ I can work around the issue of not being able to send them all at once.
mikayla

Score: 0
  • mikayla
  • Posted: Dec 09, 2014
  • Score: 0
That does not make much sense to me. I am doing this in Android (Java) and I would get and IllegalArgumentException on the '[' character immediately.

I managed to get it to work properly with the following hardcoded String:

StringBuilder urlString = new StringBuilder()
.append("http://api.toodledo.com/3/tasks/add.php?access_token=")
.append(cred.getAccessToken())
.append("&tasks=" + URLEncoder.encode("[{\"title\":\"title name\"}]", "utf-8"))
.append("&fields=folder")
.append("&f=json");

GenericUrl url = new GenericUrl(urlString.toString());
HttpRequest request = HTTP_TRANSPORT.createRequestFactory(cred).buildPostRequest(url, null);
HttpResponse response = request.execute();

- - -
However, I need this to work for my list of tasks. I am doing the json encoding before the url encoding.
The task information looks like this when fully encoded:

&tasks=%5B%7B%5C%22folder%5C%22%3A1%2C%5C%22title%5C%22%3A%5C%22TITLE+NAME%5C%22%7D%5D

Translation (only json encoded):
&tasks=[{\"folder\":1,\"title\":\"TITLE NAME\"}]

This malformed error happens regardless of whether I include the folder information.
mikayla

Score: 0
  • mikayla
  • Posted: Dec 09, 2014
  • Score: 0
The reason I had the '=' encoded was because when they pass through the GenericUrl() method used to post they disappear and I was not sure what kind of problem that could be causing with the request. I will change that back.

When I switch to the '&' I receive: {"errorCode":611,"errorDesc":"Malformed request."}

I have a JSON Array of objects instead of a JSON Object, because I am passing multiple new tasks.
mikayla

Score: 0
  • mikayla
  • Posted: Dec 08, 2014
  • Score: 0
I keep getting this error whenever I try to add a task regardless of what task data I send. I don't know what is wrong with my encoded string!

I saw another post (http://www.toodledo.com/forums/7/15019/0/error-you-didnt-send-any-tasks-to-add.html) that mentioned encoding Json before the url, but even then it doesn't work for me. The only Json encoding I should need is for the " characters, I am pretty sure.

Here is what I am sending (encoded Json before url):

http://api.toodledo.com/3/tasks/add.php?access_token%3d44a218690fa7b8e44fe5b516d0dc9b8235a1ef61?task s%3d%5B%7B%22folder%22%3A1%2C%22title%22%3A%22TASK+NAME%22%7D%5D?fields%3Dfolder?f%3djson

I simplified it to one task so it's easier to read. The task unencoded is:

[{"folder":1,"title":"TASK NAME"}]

I have even tried using the example on their add tasks site of just the "title" and a generic title test name.

Any help at all is much appreciated!!