-
Notifications
You must be signed in to change notification settings - Fork 479
Description
I'm able to create a new user via GitLab4j API. Now I want to create a new project for a specific user.
I am only able to create a new project belonging always and only to the administrator although I associate this project to a specific user through his user id:
// Create a GitLabApi instance to communicate with your GitLab server
GitLabApi gitLabApi = new GitLabApi(hostUrl+":"+port, privateAdminToken);
// Define project properties
Project project = new Project();
project.setName("progettoProva");
project.setDescription("My project for demonstration.");
project.setIssuesEnabled(true);
project.setMergeRequestsEnabled(true);
project.setPublic(true);
project.setWikiEnabled(true);
project.setSnippetsEnabled(true);
project.setVisibility(Visibility.PUBLIC);
// binding project->user via user_id <--------------------
project.setCreatorId(Integer.parseInt(userId.substring(1)));
// Create a new project for a specific user (idemtified by its own userId) and return it
Project project2 = null;
try {
project2 = gitLabApi.getProjectApi().createProject(project);
} catch (GitLabApiException e) {
e.printStackTrace();
}
// Generates a 200 OK simple result.
outputJson.put("status", "OK");
outputJson.put("message", "New project with id_project "+project2.getId()+" for id_user "+userId.substring(1)+" successfully created");
return ok(outputJson);
Where am I wrong?