Skip to content

MediaType.WILDCARD to replace MediaType.MEDIA_TYPE_WILDCARD to fix 406 error #728

Open
@wlbaker

Description

@wlbaker

In the file package org.gitlab4j.api.RepositoryFileApi, lines 423 to 435 contain references to MediaType.MEDIA_TYPE_WILDCARD which is a simple "*":

    public InputStream getRawFile(Object projectIdOrPath, String ref, String filepath) throws GitLabApiException {

	Form formData = new GitLabApiForm().withParam("ref", (ref != null ? ref : null), true);
        if (isApiVersion(ApiVersion.V3)) {
            Response response = getWithAccepts(Response.Status.OK, formData.asMap(), MediaType.MEDIA_TYPE_WILDCARD,
                "projects", getProjectIdOrPath(projectIdOrPath), "repository", "blobs", ref);
            return (response.readEntity(InputStream.class));
        } else {
            Response response = getWithAccepts(Response.Status.OK, formData.asMap(),  MediaType.MEDIA_TYPE_WILDCARD,
                "projects", getProjectIdOrPath(projectIdOrPath), "repository", "files", urlEncode(filepath), "raw");
            return (response.readEntity(InputStream.class));
        }
    }

This fails with a 406 on my version of GITLAB (V4/GitLab Enterprise Edition 13.6.5-ee). The problem is that the expected wildcard is "/". Replacing MediaType.MEDIA_TYPE_WILDCARD with MediaType.WILDCARD fixes this error. In my case, I am using the ApiVersion.V4 and have no way of testing other versions of GITLAB.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions