Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 3

"Update a file" API

I want to use update-a-file API to update a file from a Pull Request of my own repo. I have used a effective token,and I can edit the head branch of this PR witch forked from my repo,  but I still got an "Not Found". 

 

PUT /repos/:owner(pull.head.repo.name)/:repo(pull.head.repo.owner.login)/contents/:path(pull.files[0].filename)

 

Authorization: token personal-access-token
{
  "message": "my commit message",
  "content": "bXkgdXBkYXRlZCBmaWxlIGNvbnRlbnRz",
  "sha": "329688480d39049927147c162b9d2deaf885005f"(pull.files[0].sha)
}

 

sure the "maintainer_can_modify" is true; The repository is a public repository and I am the maintainer;and I have write access to the head,because I try to edit it on the web,it work.

 

2 Replies
Community Manager
Message 2 of 3

Re: "Update a file" API

If the second code block in your post is the body that you're submitting, it appears that you left out the branch name? If you're attempting to update a PR, I assume that the file that you're wanting to update isn't on the `master` branch?

 

If I'm incorrect, can you supply a minimal set of steps to reproduce the problem in a public repository so that we can take a closer look?

Copilot Lvl 2
Message 3 of 3

Re: "Update a file" API

thanks for your reply,here is my steps:

1. My username is sunui,I have a repo :https://github.com/sunui/for-robot-test

2. Sun-Xinlei forked my repo: https://github.com/Sun-Xinlei/for-robot-test

3.He update something on his branch patch-1 and send a PR to my repo from  Sun-Xinlei:patch-1 https://github.com/sunui/for-robot-test/pull/17

4.I want to edit something on this PR,I can do this on the web by Committing directly to the Sun-Xinlei:patch-1 branch.https://github.com/sunui/for-robot-test/pull/17/commits

1560484823410.jpg



I got 404 “not found”
1560489087898.jpg