ForumsDevelopersPosting carriage returns in note field when updating
Posting carriage returns in note field when updating
Author | Message |
---|---|
adrianr5 |
Hi,
I'm updating tasks by POSTing to ../2/tasks/edit.php. My note data consists of several lines with carriage returns but I can't seem to send those in the note field. Does anyone know how i can embed a CRLF into a note when updating a task? Thanks Adrian |
andrew |
Hi,
I'm also seeing the same issue. If I try to add a task with a note that contains more than line, I get Error 5: No Title Thanks, Andrew |
andrew |
OK I figured it out.
You have to replace carriage return by backslash r and newline by backslash n. If you're coding in c sharp, that means replacing the characters ' backslash r' and 'backslash n' with the strings "backslash backslash r" and "backslash backslash n" (Sorry to spell out backslash but I mean the character.) Regards, Andrew This message was edited Dec 06, 2010. |
Jake Toodledo Founder |
I just tested this and I was able to send a multi-line note using \r or \n. So both or either should work. You might be encoding the note incorrectly before sending it to the API.
If you are getting an "No Title" error, then you are probably forgetting to give a new task a title, or are setting it incorrectly. If you could post a sample API call here I can help you debug further. Here is the PHP code that I ran for this test: $tasks[0]['id'] = 12345; $tasks[0]['note'] = "one \r two \n three"; $json = json_encode($tasks); $params = "key=".$key."&tasks=".urlencode($json); postToUrl($params, "http://api.toodledo.com/2/tasks/edit.php"); |
adrianr5 |
Perfect, thanks for that. I tried every other format i could think of (%D, %A, HTML encoded BR and BR forward slash...) to no avail.
-Adrian< This message was edited Dec 06, 2010. |
andrew |
Hi,
With API 1.0 you could use the cr or lf characters directly. Now with API 2.0 you have to encode it as backslash r or backslash n. It would be helpful if the API documentation could make this clear. It's consistent with JSON encoding , but some of us don't know the rules for that. Thanks, Andrew |
Jake Toodledo Founder |
Thanks for the tip.
|
andrew |
Hi,
The new batch commands are great, but they give us some debugging challenges. If there's an encoding error anywhere in any of the tasks, we just get an error message like 'no id' or 'no title', without any clue to what task caused the error. I just got through a tricky error caused by my encoding of the " character in notes. Previously we had to encode it as %22, but now this doesn't work. We have to use backslash doublequote. Essentially we have to follow the JSON encodings for everything. These are documented here: http://json.org/ Regards, Andrew This message was edited Dec 18, 2010. |
Jake Toodledo Founder |
For batch commands, you should get back an error message in-line with all the "success" messages. You can use this to determine which task had the error. But, you are correct that if your JSON is malformed, it could cause everything to get out of wack since Toodledo won't read your tasks properly. I'll update the documentation to clarify the JSON encodings.
Thanks |
You cannot reply yet
U Back to topic home
R Post a reply
To participate in these forums, you must be signed in.