Commit 133623a0 authored by Greg Messner's avatar Greg Messner
Browse files

Fixed PUT with no entity (#101).

parent 0e33be2d
......@@ -403,7 +403,12 @@ public class GitLabApiClient {
* @return a ClientResponse instance with the data returned from the endpoint
*/
protected Response put(MultivaluedMap<String, String> queryParams, URL url) {
return (invocation(url, null).put(Entity.entity(queryParams, MediaType.APPLICATION_FORM_URLENCODED_TYPE)));
if (queryParams == null || queryParams.isEmpty()) {
Entity<?> empty = Entity.text("");
return (invocation(url, null).put(empty));
} else {
return (invocation(url, null).put(Entity.entity(queryParams, MediaType.APPLICATION_FORM_URLENCODED_TYPE)));
}
}
/**
......
......@@ -112,8 +112,7 @@ public class RepositoryApi extends AbstractApi {
/**
* Delete a single project repository branch. This is an idempotent function,
* protecting an already protected repository branch will not produce an error.
* Delete a single project repository branch.
*
* DELETE /projects/:id/repository/branches/:branch
*
......@@ -138,7 +137,7 @@ public class RepositoryApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs
*/
public Branch protectBranch(Integer projectId, String branchName) throws GitLabApiException {
Response response = put(Response.Status.OK, null, "projects", projectId, "repository", "branches", branchName, "protect");
Response response = put(Response.Status.OK, null, "projects", projectId, "repository", "branches", urlEncode(branchName), "protect");
return (response.readEntity(Branch.class));
}
......@@ -154,7 +153,7 @@ public class RepositoryApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs
*/
public Branch unprotectBranch(Integer projectId, String branchName) throws GitLabApiException {
Response response = put(Response.Status.OK, null, "projects", projectId, "repository", "branches", branchName, "unprotect");
Response response = put(Response.Status.OK, null, "projects", projectId, "repository", "branches", urlEncode(branchName), "unprotect");
return (response.readEntity(Branch.class));
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment