Post multiple files using the REST API #38965
-
While learning the REST api I try to upload files directly to GitHub. Works like a charm for a single file, but I might run foul of API limits since the data to be uploaded is small but plenty. Is there a way (wich I would have missed) to upload multiple files (better expressed: body contained payloads) with a single REST (or otherwise) call? To be clear: the "files" only exist in code, not on a file system |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
With the contents need to be example - array with two additionsmutation {
createCommitOnBranch(input: {fileChanges: {additions: [{path: "README.txt", contents: "dGVzdA=="}, {path: "README2.txt", contents: "dGVzdDI="}]}, branch: {repositoryNameWithOwner: "LangLangBart/test", branchName: "main"}, expectedHeadOid: "04d06edc5e7a838bcf8e868fae37a2ea7c0f3588", message: {headline: "test headline", body: "test body"}}) {
commit {
abbreviatedOid
}
}
} {
"data": {
"createCommitOnBranch": {
"commit": {
"abbreviatedOid": "a78b02b"
}
}
}
} PS: Useful client to interact with the GitHub API: octokit/octokit.js |
Beta Was this translation helpful? Give feedback.
-
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
With
GraphQL API
you could use Mutation.createCommitOnBranch.the contents need to be
base64
, see the Docs for more informations.example - array with two additions