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!
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")
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:
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.