From 846cfaf8d92347843754297256d959a7615bdbb8 Mon Sep 17 00:00:00 2001 From: chenzw <656469722@qq.com> Date: Mon, 13 Jan 2025 21:24:09 +0800 Subject: [PATCH] Use GitLabApiForm in post requests (#1224) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --------- Co-authored-by: Jérémie Bresson --- .../src/main/java/org/gitlab4j/api/GroupApi.java | 15 +++++++++++---- .../main/java/org/gitlab4j/api/RepositoryApi.java | 2 +- .../src/main/java/org/gitlab4j/api/TopicsApi.java | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/gitlab4j-api/src/main/java/org/gitlab4j/api/GroupApi.java b/gitlab4j-api/src/main/java/org/gitlab4j/api/GroupApi.java index 51888bf07..e199559e8 100644 --- a/gitlab4j-api/src/main/java/org/gitlab4j/api/GroupApi.java +++ b/gitlab4j-api/src/main/java/org/gitlab4j/api/GroupApi.java @@ -636,7 +636,7 @@ public Optional 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)); } @@ -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)); } @@ -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)); } diff --git a/gitlab4j-api/src/main/java/org/gitlab4j/api/RepositoryApi.java b/gitlab4j-api/src/main/java/org/gitlab4j/api/RepositoryApi.java index 20d028398..8755df8ab 100644 --- a/gitlab4j-api/src/main/java/org/gitlab4j/api/RepositoryApi.java +++ b/gitlab4j-api/src/main/java/org/gitlab4j/api/RepositoryApi.java @@ -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", diff --git a/gitlab4j-api/src/main/java/org/gitlab4j/api/TopicsApi.java b/gitlab4j-api/src/main/java/org/gitlab4j/api/TopicsApi.java index 3ca5566b2..53d31c68b 100644 --- a/gitlab4j-api/src/main/java/org/gitlab4j/api/TopicsApi.java +++ b/gitlab4j-api/src/main/java/org/gitlab4j/api/TopicsApi.java @@ -113,7 +113,7 @@ public Optional 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)); }