Can I send an HTML tags like or in a

2019-09-14 17:11发布

问题:

I'm creating a Task using a POST HTTP request, it's working fine and my task is being created on Asana. here's an example of the task I'm sending

var task = {
  data: {
    assignee: "me",
    workspace: "1234567", 
    projects: "9876543",
    parent: null,
    notes:`Full Name: ${myData.fullName}
           First Name: ${myData.firstName}
           City: ${myData.city}`
  }
 }

Once my task gets created in Asana, I would like the notes to be displayed like this, with part of the string bold:

Full Name: John Doe

First Name: John

City: San Francisco

My unsuccessful attempt was like this:

var task = {
  data: {
    assignee: "me",
    workspace: "1234567", 
    projects: "9876543",
    parent: null,
    notes:`<b>Full Name:</b> ${myData.fullName}
           <b>First Name:</b> ${myData.firstName}
           <b>City:</b> ${myData.city}`
  }
}

And I ended up getting this as a result as a note in Asana:

<b>Full Name</b> John Doe

<b>First Name:</b> John

<b>City:</b> San Francisco

回答1:

You need to make two changes in your request in order to get your desired text formatting:

  1. Use html_notes instead of notes. The notes field is treated as a literal, which is why you are seeing raw HTML instead of bolded text in Asana.
  2. Use the <strong> tag instead of <b> to bold the text.