-
Notifications
You must be signed in to change notification settings - Fork 735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect behavior of GHRepository.getReadme #150
Comments
My dirty workaround: public String getReadme(final GHRepository repository) throws Exception {
final GitHub gitHub = getRoot(repository);
final String login = getOwnerName(repository);
final String name = repository.getName();
try {
final String authorization = ReflectionUtils.get(gitHub, "encodedAuthorization");
final String apiUrl = "https://api.github.com" + repositoryApiCall(login, name) + "/readme";
final int timeout = configuration.getTimeout();
final TimeoutHttpConnector connector = new TimeoutHttpConnector(timeout);
final HttpURLConnection connection = connector.connect(new URL((apiUrl)));
try {
connection.setRequestProperty(HttpHeaders.ACCEPT, "application/vnd.github.VERSION.html");
connection.setRequestProperty(HttpHeaders.AUTHORIZATION, authorization);
connection.connect();
return IOUtils.toString(connection.getInputStream());
} finally {
try {
connection.disconnect();
} catch (final Throwable ignored) {
// Ignored.
}
}
} catch (final Throwable ex) {
logger.error("Can't fetch README file from repository {}/{}: {}", login, name, ex.getMessage());
return null;
}
} |
Closed
Duplicate of issue #99. |
I'm not sure that it's completely duplicated issue. My variant retrieves HTML document instead of Markdown ("Accept: application/vnd.github.VERSION.html") I think it will be better to add additional method to retrieve HTML content. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've got the following error, trying to fetch README file from https://github.com/matshofman/Android-RSS-Reader-Library:
The reason of this problem that readme-file was called "README.markdown" and github-api doesn't use specific Github API to fetch info about README. It just tries to download "readme" file from repository.
Additional information could be found here: https://developer.github.com/v3/repos/contents/
API call should be like this:
GET /repos/:owner/:repo/readme
UPD: It will be also useful to add method getReadmHtml and use 'application/vnd.github.VERSION.html' to retrieve HTML document.
The text was updated successfully, but these errors were encountered: