New line in desc in Trello API (VBA)
Asked by Damien Lohier:

Hello, I'm trying to create a card from API call with my VBA application.

The problem is I can't find how I can add new line / new paragraph to my description.

Here is the body I send in my POST route:

```
{"idList":"65a7a1axxxxxxxxxxxx", "name":"7 - test test", "desc": "020-T1_DEB - Part 0210000-PAT \\n \\n **Issue : **\\nThis is a text to explain the issue.", "key":MYKEY,"token":MYTOKEN}

Route: "POST", "https://api.trello.com/1/cards"

```

I tried with: \\\\n, \\n, \\n\\n, \<br\>

In most of the case, I got the symbol (\\\\n, ...), but I never got the carriage return / new line feed:
> 020-T1_DEB - Part 0210000-PAT \\\\n \\\\n \*\*Issue : \*\*\\\\nThis is a text to explain the issue.

How can I add new lines to my card's description ?

Thanks!


Answers:
author: Dag Atle Stenstad
body: Hi [@Damien Lohier](/t5/user/viewprofilepage/user-id/5407682) and welcome to the Community!   

The simplest way is to download and attach a JSON library for VBA. I personally use this one: <https://github.com/VBA-tools/VBA-JSON>

The description string, which may contain line breaks using, for example, vbNewLine, can then be converted to valid JSON using ConvertToJson("yourString")

comments: author: Damien Lohier
body: Hello, thanks for your quick response.  
I tried with VBA-JSON (I was using it to parse the API result), but I got the same behavior.

This is the query:

[https://api.trello.com/1/cards?idList=XXXXXX\&name=](https://api.trello.com/1/cards?idList=XXXXXX&name=)"7 - test test"\&desc="020-T000200_000001_0614_0671_DEB - Part 0210000-PAT\\r\\n\*\*Issue : \*\*\\r\\nThe issue"\&key...

And the card description:

![Capture d'?cran 2024-01-18 103345.png](https://community.atlassian.com/t5/image/serverpage/image-id/301152i32F1E5AAAF3635FE/image-size/large?v=v2&px=999 "Capture d'?cran 2024-01-18 103345.png")  

vbNewLine and vbCrLf give the same result:

```

Dim cardTitle As String
cardTitle = ConvertToJson("7 - test test")
Dim cardDesc As String
cardDesc = "020-T000200_000001_0614_0671_DEB - Part 0210000-PAT" & vbCrLf & "**Issue : **" & vbCrLf & "The issue."
cardDesc = ConvertToJson(cardDesc)
Dim httpResult As String
httpResult = http.SendRequest("POST", "https://api.trello.com/1/cards?idList=" & newList & "&name=" & cardTitle & "&desc=" & cardDesc & "&key=" & APIKey & "&token=" & token, "", False)

```


author: Dag Atle Stenstad
body: Ah, you pass the variables as parameters in the URL. You can try using %0A for a line break since it's in the URL (similar to how spaces are replaced with %20).


author: Dag Atle Stenstad
body: You don't need to parse to JSON when you send it in the URL. That's only necessary if you're sending it as a JSON object (which is recommended).   

[Here's an example of how I create a JSON object to create a new Jira issue](https://github.com/dagiz007/ExcelAddin4Atlassian/blob/master/scr/clsJira.cls#L204)  


author: Damien Lohier
body: I didn't know we can call with JSON Payload !

Thanks, it works fine.

I didn't need to convert the name and the description of the card before sending it:

```
Dim payload As String
payload = "{" & _
"""idList"":" & ConvertToJson(list) & "," & _
"""name"":" & name & "," & _
"""desc"":" & desc & "," & _
"""key"":" & ConvertToJson(APIKey) & "," & _
"""token"":" & ConvertToJson(token) & _
"}"
http.SendRequest("POST", "https://api.trello.com/1/cards", payload, False)
```

<br />

I may create a new ticket for attachment upload. I tried with your code but it does not work me (I receive Status 400: Bad request).

Thanks again for your help !


Tags: api