I try to add a comment with multiple lines via the api:
curl --request POST \ --url 'https://api.trello.com/1/cards/{id}/actions/comments?text={text}
I tried the following values for {text} , without success:
Line 1 <br /> Line 2
Line 1 %0A Line 2
Line 1 (space) Line 2
Line 1\ Line 2
Line 1 \xA Line 2
Line 1 \n Line 2
Hallo @Remco Kragt _exposure_
You use the URL-encoded newline character, %0A if you are declaring the value of the text parameter in the request path.
If that's not working, then you haven't properly declared the Content-Type header as being application/json
Thanks for your reply David,
So I tried it again:
"text": "Line 1%0ALine 2"
Result
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
"text": "Line 1%0ALine 2" is JSON, not plain text.
If you're going to use cURL's --data parameter and declare the value of text parameter in the request body using JSON instead of using plain text and as a request path parameter, as you've shown in your original question, then the \n character is used:
{
"text": "Line 1\nLine 2\nLine3"
}
Broadly speaking, when doing PUT and POST requests, it really is best practice to declare ALL parameters, including the key and token parameters, in the request body, not as path parameters:
...which in the UI would be rendered to the user as:
The reason for declaring ALL parameters in the request body for PUT and POST requests is consistency. Many other REST APIs from other products enforce that method, plus many types of parameters, such as nested arrays, have no equivalent in plain text, so they cannot be expressed when declared in the request path.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.