Skip to content

Commit

Permalink
Use GitLabApiForm in post requests (#1224)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Jérémie Bresson <jeremie.bresson@unblu.com>
  • Loading branch information
otary and jmini authored Jan 13, 2025
1 parent d1e1f05 commit 846cfaf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
15 changes: 11 additions & 4 deletions gitlab4j-api/src/main/java/org/gitlab4j/api/GroupApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ public Optional<Group> getOptionalGroup(Object groupIdOrPath) {
* @throws GitLabApiException if any exception occurs
*/
public Group createGroup(GroupParams params) throws GitLabApiException {
Response response = post(Response.Status.CREATED, params.getForm(true), "groups");
Response response = post(Response.Status.CREATED, new GitLabApiForm(params.getForm(true)), "groups");
return (response.readEntity(Group.class));
}

Expand All @@ -651,8 +651,11 @@ public Group createGroup(GroupParams params) throws GitLabApiException {
* @throws GitLabApiException at any exception
*/
public Group updateGroup(Object groupIdOrPath, GroupParams params) throws GitLabApiException {
Response response =
putWithFormData(Response.Status.OK, params.getForm(false), "groups", getGroupIdOrPath(groupIdOrPath));
Response response = putWithFormData(
Response.Status.OK,
new GitLabApiForm(params.getForm(false)),
"groups",
getGroupIdOrPath(groupIdOrPath));
return (response.readEntity(Group.class));
}

Expand Down Expand Up @@ -2455,7 +2458,11 @@ public void revokeGroupAccessToken(Object groupIdOrPath, Long tokenId) throws Gi
*/
public GroupHook addWebhook(Object groupIdOrPath, GroupHookParams groupHookParams) throws GitLabApiException {
Response response = post(
Response.Status.CREATED, groupHookParams.getForm(), "groups", getGroupIdOrPath(groupIdOrPath), "hooks");
Response.Status.CREATED,
new GitLabApiForm(groupHookParams.getForm()),
"groups",
getGroupIdOrPath(groupIdOrPath),
"hooks");
return (response.readEntity(GroupHook.class));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ public void generateChangelog(Object projectIdOrPath, String version) throws Git
public void generateChangelog(Object projectIdOrPath, ChangelogPayload payload) throws GitLabApiException {
post(
Response.Status.OK,
payload.getFormData(),
new GitLabApiForm(payload.getFormData()),
"projects",
getProjectIdOrPath(projectIdOrPath),
"repository",
Expand Down
2 changes: 1 addition & 1 deletion gitlab4j-api/src/main/java/org/gitlab4j/api/TopicsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public Optional<Topic> getOptionalTopic(Integer id) {
* @throws GitLabApiException if any exception occurs
*/
public Topic createTopic(TopicParams params) throws GitLabApiException {
Response response = post(Response.Status.CREATED, params.getForm(true), "topics");
Response response = post(Response.Status.CREATED, new GitLabApiForm(params.getForm(true)), "topics");
return (response.readEntity(Topic.class));
}

Expand Down

0 comments on commit 846cfaf

Please sign in to comment.