API: when creating a new discussion thread, what to specify for position[line_range]?

From the API documentation I have been able to create new discussions when the line of code which the discussion had to be displayed on did not contain any changes… however when I want to create a new discussion thread on a line where there’s been a change, I need to specify the line_range hash.

From querying for other discussions, I can see that the line_range content looks like:
“line_range”: {
“start”: {
“line_code”: “32c57701ddbf050f8195fb262a5eff6487014a41_8_7”,
“type”: “new”,
“end”: {
“line_code”: “32c57701ddbf050f8195fb262a5eff6487014a41_8_7”,
“type”: “new”

What I DON’T know however, is how to get that line_code information!
With the bit here, it looks like the hash is a SHA1 value, with the before/after line numbers added at the end… but where does the “32c57701ddbf050f8195fb262a5eff6487014a41” value come from in the first place? If I have to provide it as part of the line_range, then I obviously have to know how to find/create that value… and the documentation does NOT give me that…

Help!! Please!!

I had the same problem and solved it by computing the SHA1 of the filename, just like in lib/gitlab/git.rb

I used this in my Python script: