Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

New line in desc in Trello API (VBA)

Damien Lohier January 17, 2024

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!

 

 

1 answer

1 vote
Dag Atle Stenstad
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 17, 2024

Hi @Damien Lohier 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")

Damien Lohier January 18, 2024

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="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

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)

Dag Atle Stenstad
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 18, 2024

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).

Dag Atle Stenstad
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 18, 2024

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

Damien Lohier January 19, 2024

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)


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 !

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events