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

Content API in GitHub

Solved! Go to Solution.

Github content api is not giving the correct commit id in its 'sha' key value.

 

https://github.***.com/api/v3/repos/exampleowner-Management/examplerepo/contents/Compile/Teradata/Tables?access_token=*****

 

I'am using the above api and the sha key value is wrong.

the result of api call is :

[
{
    "name": "file1.ddl",
    "path": "Compile/Tables/test",
    "sha": "1cef8efa8694678e3b7ab230a6a891afa1a1996d",
    "size": 8196,
    "url": "***",
    "html_url": "***",
    "git_url": "***",
    "download_url": "***",
    "type": "file",
    "_links": {
        "self": "***",
        "git": "***",
        "html": "***"
    }
}]

 

how to get the latest comimit for each file?

4 Replies
Community Manager
Message 2 of 5

Re: Content API in GitHub

Hi @anvinraj,

 

Thanks for being here! Are you getting the last event? ie:

  •  the last push event: Most recent commit done (on any branch), pushed by a user to the repo.

 
Thanks for being here, sharing, and keeping our community awesome!
Best,
AndreaG

Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!

Copilot Lvl 2
Message 3 of 5

Re: Content API in GitHub

Hi @AndreaGriffiths11,

No, it is not showing the latest push details(commit id).

 

Solution
Community Manager
Message 4 of 5

Re: Content API in GitHub

Hi @anvinraj,

 

For The Commits API, there's an endpoint for fetching a list of commits on a repository. You could utilize the sha value to start listing commits from a specific SHA or branch:

 

https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository

 

Example:

https://api.github.com/repos/github/linguist/commits?sha=dev

 

If you're interested in fetching every commit, I recommend leveraging pagination as well:

https://developer.github.com/v3/#pagination

 

I hope this helps 

Thanks for being here, sharing, and keeping our community awesome!
Best,
AndreaG

Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!

Ground Controller Lvl 1
Message 5 of 5

Re: Content API in GitHub

Thank you so much for helping.