How to submit a multiline description in the Create MR api call?

I’m trying to create a MR with a multiline description through the API.

I tried submitting it with:

  1. \n: \n displayed
  2. \n\n: \n\n displayed
  3. \r\n: \r\n displayed
  4. \r\n\r\n: \r\n\r\n displayed

  5. : works but then formatting is wrong. E.g if we start the description with “# Title”, the whole description will follow the formatting.

Is there an easy way to pass it?

Here is my command:

curl \
  -XPOST \
  -s \
  --header "PRIVATE-TOKEN: TOKEN" \
  "https://gitlab.com/api/v4/projects/XXX/merge_requests" \
  --data "id=XXX" \
  --data "source_branch=test-mr-port" \
  --data "target_branch=master" \
  --data "remove_source_branch=true" \
  --data "title=WIP: [XXX] TEST-DO-NOT-MERGE" \
  --data "description=# Title\n\nThis MR has been automatically generated\n\nHello" \
  --data "assignees_ids=XXX" \
  --data "reviewer_ids[]=XXX" \
  --data "reviewer_ids[]=XXX" \
  --data "draft=false" \

Thanks

%0A is the URL encoded version of a newline character.
Try this:

--data "description=# Title%0A%0AThis MR has been automatically generated%0A%0AHello" \

This also corrects formatting.