简体   繁体   中英

How to access newly created files on a repo via the Github API?

I can access existing files just fine. For example, this works perfectly to retrieve the contents of README.md at the root of the repo:

https://api.github.com/repos/kevindecent/decent-salesforce/contents/README.md

However, if I create a new file at the root of the repo called 'test.txt', I get a 'Not Found' error when I try to retrieve it like so:

https://api.github.com/repos/kevindecent/decent-salesforce/contents/test.txt

Why can't I access newly created files at the root of the repo, using the Github API? Is my access token corrupt or something?

Turns out I was making a simple mistake. I was returning the contents of a forked version of the repo using this URL:

https://api.github.com/repos/<Github User Name>/decent-salesforce/contents

When I should've returned the contents at the organization level using this URL:

https://api.github.com/repos/<Github Organization Name>/decent-salesforce/contents

Double-check your PAT (Personal Access Token) , and its associated scope (at least repo ), as well as its possible expiration date.

Use said token directly in command-line to see what is going on:

curl -v -i -u your_username:$token https://api.github.com/...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM