Skip to content
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

Get content from a directory #9

Open
apiphoque opened this issue Mar 28, 2023 · 1 comment
Open

Get content from a directory #9

apiphoque opened this issue Mar 28, 2023 · 1 comment

Comments

@apiphoque
Copy link

Description

Hi everyone, I am having some troubles with this specific function : repoGetContents(...)

When I use this with a filename, it works perfectly, even if the file is in a directory.

However, when I do it with a directory I get an error :

java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $
	at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:395) ~[gson-2.9.1.jar:na]
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:259) ~[gson-2.9.1.jar:na]
	at com.google.gson.Gson.fromJson(Gson.java:1058) ~[gson-2.9.1.jar:na]
	at com.google.gson.Gson.fromJson(Gson.java:1016) ~[gson-2.9.1.jar:na]
	at com.google.gson.Gson.fromJson(Gson.java:959) ~[gson-2.9.1.jar:na]
	at io.gitea.JSON.deserialize(JSON.java:137) ~[java-gitea-api-1.16.8.jar:na]
	at io.gitea.ApiClient.deserialize(ApiClient.java:720) ~[java-gitea-api-1.16.8.jar:na]
	at io.gitea.ApiClient.handleResponse(ApiClient.java:923) ~[java-gitea-api-1.16.8.jar:na]
	at io.gitea.ApiClient.execute(ApiClient.java:850) ~[java-gitea-api-1.16.8.jar:na]
	at io.gitea.api.RepositoryApi.repoGetContentsWithHttpInfo(RepositoryApi.java:9215) ~[java-gitea-api-1.16.8.jar:na]
	at io.gitea.api.RepositoryApi.repoGetContents(RepositoryApi.java:9198) ~[java-gitea-api-1.16.8.jar:na]
[...]

I think the problem is that this function returns a ContentsResponse, and in the case of a directory, we want a List<ContentsResponse>.

    public ContentsResponse repoGetContents(String owner, String repo, String filepath, String ref) throws ApiException {
        ApiResponse<ContentsResponse> resp = repoGetContentsWithHttpInfo(owner, repo, filepath, ref);
        return resp.getData();
    }

Note : I tested the directory name multiple times, with the actual Gitea API on postman, it works, I also tried multiples writing for my directory name such as "dir" "/dir" "dir/" or "/dir/', they all get the same error.

Maybe I'm missing something, its the first time I'm using this projet...

Gitea version

1.18.5

Can you reproduce the bug on the Gitea demo site?

As I mentionned I tried the routes with Postman and it works fine, I get a list of ContentResponse.

Operating system

Windows 10

How are you running Gitea ?

I have a docker image running on my computer, its on localhost:3000

@Nio520
Copy link

Nio520 commented Aug 8, 2023

I have encountered the same issue. Did you by any chance find a way to fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants