Adding files to a repository and attaching them to an issue

Is there a way to add files to a repository through the REST API the same way they would have been added if I used the drag-and-drop functionality while creating an issue using the website?

When creating an issue it’s possible to attach files to the issue by dragging and dropping files, a link looking something like:
https://github.com/{username}/{repository}/files/{somenumber}/{file}
is created, and is referenced in the issue. I was hoping I could first add the files, somehow get their links, and then reference them in the issue since I can’t add files to the issues right away during their creation using the REST API.

Afaict, everything uses this undocumented API:
https://github.com/upload/policies/assets

@jsoref the link you sent doesn’t work, it leads to a 404.

Yep, that’s the endpoint. As I said, it appears to be undocumented.

You can ask https://support.github.com for help with it or alternatives.

It’s what the web ui uses…

1 Like