Sahil Dhankhar
Sahil Dhankhar

Reputation: 3656

github api v3 to fetch contents of a file from a particular branch other than master

How to use github v3 contents api to fetch a file's contents from a particular branch http://developer.github.com/v3/repos/contents/ i tried these options https://api.github.com/repos/'org_name'/'repo_name'/contents/'file_path' https://api.github.com/repos/'org_name'/'repo_name'/contents/'file_path'/?ref=branch_name or quite a few options , but it fetches the file contents from the masters branch only.

but i need to fetch the contents from a branch other than master. I know i am missing something very basic , but not a figure out what. thanks in advance

Upvotes: 8

Views: 14494

Answers (2)

Laura
Laura

Reputation: 11

For anyone on a Mac that comes across this and can't figure out why they're seeing the following response to their cURL (like me):

zsh: no matches found:

You need to escape the '?' so it looks more like:

https://api.github.com/repos/google/tracing-framework/contents/index.html\?ref=gh-pages

Upvotes: 1

Ivan Zuzak
Ivan Zuzak

Reputation: 18772

That's strange because it seems to work for me. Here is the URL for fetching the index.html file in the gh-pages branch from the tracing-framework repo from Google's GitHub organization:

https://api.github.com/repos/google/tracing-framework/contents/index.html?ref=gh-pages

The index.html file doesn't exist in master.

Can you give the exact URL you are trying?

Upvotes: 25

Related Questions