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

Use GitLabApiForm in post requests #1224

Merged
merged 16 commits into from
Jan 13, 2025
Merged

Use GitLabApiForm in post requests #1224

merged 16 commits into from
Jan 13, 2025

Conversation

otary
Copy link
Contributor

@otary otary commented Jan 3, 2025

A side effect of #1067 is that some methods no longer work, since they are not sending a jakarta.ws.rs.core.Form.


Example when creating a group webhook:

org.gitlab4j.api.GitLabApiException: url is missing
	at org.gitlab4j.api.AbstractApi.validate(AbstractApi.java:784)
	at org.gitlab4j.api.AbstractApi.post(AbstractApi.java:402)
	at org.gitlab4j.api.GroupApi.addWebhook(GroupApi.java:2457)

Http trafic (see Content-Type header)

INFO: 1 - Sending client request on thread main
1 > POST https://********/api/v4/groups/********/hooks
1 > Accept: application/json
1 > Content-Type: application/json
1 > PRIVATE-TOKEN: ********

When it should be:

INFO: 1 - Sending client request on thread main
1 > POST https://********/api/v4/groups/********/hooks
1 > Accept: application/json
1 > Content-Type: application/x-www-form-urlencoded
1 > PRIVATE-TOKEN: ********

Affected:

  • GroupApi.addGroup(..)
  • GroupApi.updateGroup(..)
  • GroupApi.addWebhook(..)
  • RepositoryApi.generateChangelog(..)
  • TopicsApi.createTopic(..)

@jmini
Copy link
Collaborator

jmini commented Jan 7, 2025

Can you elaborate what this fix is for?

This might be a side effect of #1067 but I would like to understand what is wrong.

Also I imagine other cases are affected as well.

@otary
Copy link
Contributor Author

otary commented Jan 8, 2025

create project and update project errors using gitlab4j,i try to fix it

@jmini jmini changed the title fix addGroup、updateGroup、addWebhook exception Use GitLabApiForm in post requests Jan 13, 2025
@jmini
Copy link
Collaborator

jmini commented Jan 13, 2025

Ok I did more testing, found some other cases, I have update the description and the title of this pull request.

This is really good finding @otary 🎉 . Thank you a lot.

@jmini jmini merged commit 846cfaf into gitlab4j:main Jan 13, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants