I’ve been trying to automate the creation of discussions on security related findings during a merge request. I’m unable to create a request via API (GraphQL or REST) that can refer to a line range. I believe the closest I got it something like this:
curl --request POST --header "PRIVATE-TOKEN: $APITOKEN" \
--form "position[position_type]=text" \
--form "position[base_sha]=b43c2943324f3a641d6cbc12941980104d11e5c8" \
--form "position[head_sha]=78c44fe5181a6f8538befdea088f36086657d561" \
--form "position[start_sha]=b43c2943324f3a641d6cbc12941980104d11e5c8" \
--form "position[new_path]=Controller.java" \
--form "position[old_path]=Controller.java" \
--form "position[new_line]=7" \
--form "position[line_range][start][line_code]=71c8c635708dd177dc44033490f6562c3e6ae303_0_1" \
--form "position[line_range][start][type]=new" \
--form "position[line_range][start][new_line]=1" \
--form "position[line_range][end][line_code]=71c8c635708dd177dc44033490f6562c3e6ae303_0_1" \
--form "position[line_range][end][type]=new" \
--form "position[line_range][end][new_line]=7" \
--form "body=test comment body" https://gitlab.com/api/v4/projects/40276465/merge_requests/22/discussions
But this send me back this error message:
{"message":"400 Bad request - Note {:position=>[\"must be a valid json schema\"]}"}
Can anyone guide me into doing so via python or curl?