Get Content Question - last update timestamp


#1

Hi,

I have a use case where the integration does a get content as per this. Is there a simple way of working out the last update timestamp of this without also doing a get on the file blob?

So, if I am accessing a folder, and get its contents, I get back an array of files. Awesome. However, if i need to work out the last update field, I need to go get each individual file and work out the date. Is there are easy way to avoid this?

Thanks so much.

Tat

p.s. as far as I can tell, this is not possible even if I get the tree and look at it either.


#2

Somewhat related issue, (or not): The download_url i think is incorrect when getting the contents of a directory from an integration. It comes back with a token that does not look like the token of the integration that accessed it.

Can you guys have a look at this? Am i just not reading the documents and not understanding what should be coming back on the download url?

Thanks so much.

Tat


#3

Hi @tathagatbanerjee,

There’s no need to fetch each individual file. The recommended way of doing this is to fetch the list of commits for that path (a path can be either a file or a folder):

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

The commits returned by the API will be ordered, and the most recent commit will be the first in the returned list. So, if you take the timestamp of that first commit (included in the API’s response), you will get the time of the most recent update. So, you can fetch that date with 1 additional request instead of n, where n is the number of files in a folder.


#4

:wave: @tathagatbanerjee

This is expected behavior - the token in the download_url is should not be your Integration token.
The token you see there is for fetching raw contents from raw.githubusercontent.com which isn’t part of the API.

As this is true, we don’t recommend that you fetch raw contents of a file via the API, however if that is necessary we recommend using this documented approach : https://developer.github.com/v3/repos/contents/#custom-media-types which asks you to pass in a special media type in the Accept header.


#5