GitHub API for creating a file

So, I'm trying to get acquainted with the GitHub API. I use cURL commands to implement some of their core functions. I can correctly create basic permission and repository creation. I am currently trying to create a file in the repository using their API and encountered a "message": "Not found" error as an answer.

Their documentation suggests the following:

PUT /repos/:owner/:repo/contents/:path

I came up with this as the equivalent of cURL:

curl -H 'Authorization: <token>' -d '{"path": "test.txt", "message": "Initial Commit", "committer": {"name": "<name>", "email": "<email>"}, "content": "bXkgbmV3IGZpbGUgY29udGVudHM=", "note":"Test Commit"}' https://api.github.com/repos/InViN-test/test_repo1/contents/test.txt

I think the problem is with the API URL that I use at the end, but I cannot figure out what the URL should look like.

This is what I used to create the repository:

curl -i -H 'Authorization: <token>' -d '{"name": "test_repo1", "message": "Initial Commit", "committer": {"name": "<name>", "email": "<email>"}, "content": "bXkgbmV3IGZpbGUgY29udGVudHM=", "note":"Test Commit"}' https://api.github.com/user/repos

URL- , , : user/repos . , user/repos/repo, .

- ?

StackOverflow, , , , .

EDIT: TimWolla .

API GitHub:

curl -i -X PUT -H 'Authorization: token <token_string>' -d '{"path": "<filename.extension>", "message": "<Commit Message>", "committer": {"name": "<Name>", "email": "<E-Mail>"}, "content": "<Base64 Encoded>", "branch": "master"}' https://api.github.com/repos/<owner>/<repository>/contents/<filename.extension>

:

curl -i -X PUT -H 'Authorization: token f94ce61613d5613a23770b324521b63d202d5645' -d '{"path": "test4.txt", "message": "Initial Commit", "committer": {"name": "Neil", "email": "neil@abc.com"}, "content": "bXkgbmV3IGZpbGUgY29udGVudHM=", "branch": "master"}' https://api.github.com/repos/InViN-test/test_repo1/contents/test4.txt

+4
1

curl HTTP- (PUT ) -X:

curl -X PUT -H 'Authorization: …' yadayada

, , 500, :

{"message": "Initial Commit","content": "bXkgbmV3IGZpbGUgY29udGVudHM="}

.

+4

Source: https://habr.com/ru/post/1531061/


All Articles