I'm trying to create discussion on specific line of changed file.
Request i make:
await axios.post('https://gitlab.<project>/api/v4/projects/<project id>/merge_requests/103/discussions', {
body: 'test123',
'position[base_sha]': '9f4284ba82fc0667464ca8abaa76b334415278fc',
'position[start_sha]': '9f4284ba82fc0667464ca8abaa76b334415278fc',
'position[head_sha]': 'c6272616033ddcceb3ced2d37c0fd75a8cf5472f',
'position[position_type]': 'text',
'position[new_path]': 'LICENSE',
'position[new_line]': 80,
'position[old_path]': 'LICENSE',
'position[old_line]': null,
'position[line_range][start_line_code]': '0398ccd0f49298b10a3d76a47800d2ebecd49859_0_355',
'position[line_range][end_line_code]': '0398ccd0f49298b10a3d76a47800d2ebecd49859_0_355',
'position[line_range][start_line_type]': 'old',
'position[line_range][end_line_type]': 'old',
});
Most of the body values are taken from inspecting the browser and seeing what request gitlab makes when i create the thread manually.
The request results in simple thread that does not appear on top of a file, the documentation does not explain well the body fields and their functionality so I'm currently stuck with this.
I'm unsure if those fields are correct, i took the start_line_code
and end_line_code
from the gitlab request i saw in the browser:
'position[line_range][start_line_code]': '0398ccd0f49298b10a3d76a47800d2ebecd49859_0_355',
'position[line_range][end_line_code]': '0398ccd0f49298b10a3d76a47800d2ebecd49859_0_355',
'position[line_range][start_line_type]': 'old',
'position[line_range][end_line_type]': 'old',
How the thread looks like:
What i expect it to look like:
What is the correct way of creating thread that appears on top of a file?