Search code examples
htmlasana

Formatting issue while creating new tasks using API


I am automating the "Use as a Template (Copy Project)" action via API but API does not support it directly.

For that, I need to get one "note" from a task and copy it to another task using API, for that I first fetched the task details using API, here is the "notes" tag I received:

"notes": "\n\nClick on the Down Arrow button to the right of the project \nChoose \"Use as a template (Copy Project)\"\n\nChange the name to:  \"PS - CustomerName - ProjectTitle\"\n(For TM Projects: Change name to \"TM - CustomerName - SENumber (Time)\" )\n\nFind your new project in the project list in the left panel and re-order it alphabetically.\n\nChange the colour."

But when I pass the same "notes" to another task using API, it does not convert \n to new lines, and creating the notes with \n. Can you please suggest me how to solve this problem?


Solution

  • Sending a "\n" in JSON does indeed map to a newline. If you're using formdata you would need to replace the "\n" with a literal newline character - if you're using JSON, make sure you're not accidentally escaping the "\n" into something like "\n" (or worse).