Asana API notes not considering new line or \n or line break

In html_notes or notes tag I am passing \n in newline place. Its showing error message “Could not parse request data, invalid JSON”. If I replace that \n value with any tag like

,
,
  • its considering as text. I am using Json request using c#. Can you please help me to solve the issue?

    Here is the code:
    string jsonString={ “data”: { “name”: “task name”,“parent”: null, “html_notes”: "sdf\njjj ", “assignee_status”: “inbox”, “assignee”: {“id”: 123, “name”: “yhyhyh”}, “collaborator”: 3434,“workspace”: 34334, “due_on”: null, “id”: 3434, “project”: 3434343 }}

    HttpWebRequest request = ( HttpWebRequest ) WebRequest.Create(“https://app.asana.com/api/1.0/tasks”);
    request.Method = “POST”;
    request.ContentType = “application/json”;
    request.ContentLength = jsonString.Length;
    request.Headers.Add(“Authorization”, “Bearer +APIKEY”);
    var data = Encoding.ASCII.GetBytes(jsonString);
    using ( var stream = request.GetRequestStream() )
    {
    stream.Write(data, 0, data.Length);
    }
    var response = ( HttpWebResponse ) request.GetResponse();
    var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();

  • You might find this site helpful jsonlint.com or this site jsonviewer.stack.hu/
    Anyway, I’m a Python guy and I can get your code to parse using the validator above by removing the type of string. I can also get the Viewer on the jsonviewer site to parse it out correctly if I remove your string type. Your jsonString returns this error:

    Error: Parse error on line 1:
    string jsonString =
    ^
    Expecting ‘STRING’, ‘NUMBER’, ‘NULL’, ‘TRUE’, ‘FALSE’, ‘{’, ‘[’, got ‘undefined’ <<This usually means an extra comma somewhere but I don’t think that is the issue.

    If I remove the type of string from in front of jsonString= it validates; so I’m assuming [I’m not a JSON guy] that you are setting an explicit type of string while filling your array with non-strings?
    In Python your code runs by simply changing your nulls to None and removing the word string [Python doesn’t Type arrays and null is not a reserved word].

    Sorry, If I’ve not helped you at all, but maybe some of this will get you in the right direction.

    I got the solution by replacing @ before \n.
    Here is the example syntax
    notes= notes.Replace(“\r\n”, @“\n”);

    Solution above isn’t working for me.

    Seriously, having no support for p or br tags feels like a bad joke.
    Now I’m late on schedule because I can’t add a newline to my html thanks to your crappy pathetic API.

    Did you try using “\n”?
    It works in my code. You just have to add “\n” in your “notes” object.
    {"notes": "Hello. \n World"}

    I know, the “html_notes” doesn’t support “br” or “p” HTML tag.
    It’s kinda ‘trolling developer’.
    Why would they have “html_notes” if they didn’t support using “br” or “p”?
    I hope they fixed this bug later.

    I am creating a form and need to show multiple lines on a separate line. What is the best way to display text on a separate lines?

    Hi @anon6535477 and welcome to the forum!

    The thread you’ve posted in is for software developers using the Asana programming interface. It’s best if you start a new topic in the Tips and Tricks forum section. Thanks!