API: Problem with POST /repos/{owner}/{repo}/issues/{index}/assets

Hi,

I have a self-hosted gitea-server on a Windows machine.

I’m trying to post files as attachment to an issue:

curl -X "POST" -u "***" "http://***/api/v1/repos/***/***/issues/comments/43/assets" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "attachment=@test.txt;type=text/plain"

The server answers with 201:

{"id":6,"name":"test.txt","size":2356,"download_count":0,"created_at":"2024-11-22T08:21:20+01:00","uuid":"714eacd0-f244-4480-8279-73b2a11d7ab2","browser_download_url":"http://***/attachments/714eacd0-f244-4480-8279-73b2a11d7ab2"}

The provided link does work, and looking into the folder of my gitea-instance I can see the created file.
However, the file is not attached to the issue, I can’t see it in the browser, and

curl -X "GET" -u "***" "http://***/api/v1/repos/***/***/issues/43/assets"

returns

[]

What am I doing wrong?

Thanks in advance, Philipp

I found the issue, my URL was wrong:

http://***/api/v1/repos/***/***/issues/comments/43/assets

Somehow, the path contained /comments, when it shouldn’t have.

However, I now wonder, why the API did accept the request in this situation.
In my opinion, the requests should have been rejected with 400 Bad Request or something similar.