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”}, “follower”: 3434,“workspace”: 34334, “due_on”: null, “id”: 3434, “project”: 3434343 }}

    HttpWebRequest request = ( HttpWebRequest ) WebRequest.Create(“”);
    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();

  • #2

    You might find this site helpful or this site
    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");