I have an integration that creates Asana tasks based on a Google form being submitted. It builds a valid rich text Description using supported HTML tags, example as follows:
<body>
<ul>
<li><strong>Item 1: </strong>Data From Form</li>
<li><strong>Item 2: </strong>Data From Form</li>
</ul>
</body>
Up until today, that has been displaying properly in the created tasks’ description fields, with bullet points for each list item and a new line for each one, ie:
Form Item 1: Data from form
Form Item 2: Data form form
Today, all of the tasks previously created are showing with multiple lines between each item and empty bullet points, like this:
Form Item 1: Data from form
Form Item 2: Data from form
The fact it’s not just newly created tasks that are not displaying correctly seems to indicate it’s something to do with Asana’s rendering of the HTML.
Has anything changed? I can’t see anything related in the change log. Or has anyone else seen this issue?
It looks like the issue is caused by the new line characters in the html_notes field. This is expected behavior — to remove the extra spacing between list items, you’ll need to eliminate the new lines from the HTML string in your request body.
Right now, your request looks something like this:
<body>\n
<ul>\n
<li><strong>Item 1: </strong>Data From Form</li>\n
<li><strong>Item 2: </strong>Data From Form</li>\n
</ul>\n
</body>
If you convert it into a single line, it should render correctly. For example:
PUT {{baseUrl}}/tasks/:task_gid
{
"data": {
"html_notes": "<body><ul><li><strong>Item 1: </strong>Data From Form</li><li><strong>Item 2: </strong>Data From Form</li></ul></body>"
}
}
Could you please share a code snippet or the exact request you’re sending? I haven’t seen any similar reports so far, but if the behavior has indeed changed, I’ll run some tests and raise it with the relevant team.
Any additional details you can provide would be super helpful!
// Create the Asana task
try {
asanaTaskID = createAsanaTask(groupedData, asanaTaskDescription);
if (!asanaTaskID) {
Logger.log("Asana task could not be created. Aborting.");
return; // Exit if Asana task cannot be created
}
} catch (error) {
Logger.log(`Error creating Asana task: ${error.message}\nStack: ${error.stack}`);
SpreadsheetApp.getUi().alert("Error", `An error occurred while creating the Asana task. Check logs for details.`, SpreadsheetApp.getUi().ButtonSet.OK);
return null; // Exit if Asana task cannot be created
}
Which calls the Asana API:
function createAsanaTask(groupedData,taskDescription) {
// Validate required Asana credentials and project ID
if (!ASANA_ACCESS_TOKEN || !ASANA_PROJECT_ID) {
Logger.log("Error: Asana Access Token or Project ID is not configured. Cannot create subtask.");
return null;
}
// Create the data structure that will be sent to the Asana API
const payload = {
data: {
name: `${groupedData.generalInfo["Legal Name"]}, ` +
`${Utilities.formatDate(groupedData.generalInfo["Start Date"], Session.getScriptTimeZone(), 'MMMM yyyy')} - ${Utilities.formatDate(groupedData.generalInfo["End Date"], Session.getScriptTimeZone(), 'MMMM yyyy')}, ` +
`${groupedData.generalInfo["Project Title"], "XXXX-XXXX"}`,
html_notes: taskDescription,
projects: ASANA_PROJECT_ID
},
};
const url = `${ASANA_API_BASE_URL}/tasks`;
const options = {
method: "post",
headers: {
Authorization: `Bearer ${ASANA_ACCESS_TOKEN}`,
"Content-Type": "application/json",
},
payload: JSON.stringify(payload),
muteHttpExceptions: true // Ensure a response is always returned, even on HTTP errors
};
// Call the Asana API to create the task and get the task ID for the created task back as a response
try {
const response = UrlFetchApp.fetch(url, options);
const jsonResponse = JSON.parse(response.getContentText());
const taskID = jsonResponse.data.gid; // Extract the task ID
Logger.log("Task Created with ID: " + taskID);
return taskID;
}
catch (error) {
Logger.log(`Error creating Asana task: ${error.message}\nStack: ${error.stack}`);
return null; // Exit if data processing failed
}
}
The issue here is caused by the whitespaces in the html_notes field you’re sending. You can easily confirm this by logging the raw JSON of your request, for example:
As far as I remember, this behavior has always been the same (I’ve run into it myself). It’s both helpful and tricky — great if you want to add line breaks without using <br/>, but it does require some extra care when formatting content programmatically.
To fix it, you can try one of the following options:
I still think something must have changed somewhere there, as the “wrong” code has been creating tasks with the format looking as expected for several months now, and then suddenly the formatting on already created as well as new tasks changed, with no updates to the code at our end.
But I’m happy that it’s resolved for now in any case!