Example for defining PATH to single file with LAST-MODIFIED GET call?

rest-api

#1

This should be so straightforward, but having a hard time determining how to define the path to one file in the root directory that I want to pull the last commit from. The only hit I can get is for everything from the branch - which I don’t want …

i.e. last-modified?at=

Any help would be greatly appreciated!


#2

The rest docs show that you need to do a GET request to https://{bitbucket_url}/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/last-modified/{path}?at={commitId}

If you were trying to get the path for a file called README.md in the root of your git repository, then the url would be:
https://{bitbucket_url}/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/last-modified/README.md?at={commitId}

If you were trying to get the file some_folder/some_file then the URL would be:
https://{bitbucket_url}/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/last-modified/some_folder/some_file?at={commitId}

Hope that helps,
Kristy


#3

Thanks for replying Kristy. Does it have to have a commit id? That is the info i’m trying to pull from this call in the first place, so confused by that. I still can’t get a hit even with the valid commit id on this file. Still only able to retrieve everything from the branch with the call above last-modified?at=myBranch

I’m able to successfully use the browse GET and PUT to update a file, but that of course requires a commit id.


#4

I ended up just pulling all files from the root level and parsed for the one I need.


#5

I believe that you can use a ref (i.e. branch or tag) for the at field too.
If it’s still not working, can you please provide an example of the request you’re making? Can you also please expand on what you’re trying to do?