Content API in GitHub

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?

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.

Hi @andreagriffiths11,

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

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 

Thank you so much for helping.