i am working on Gitlab CI, more specifically with the API and the pipeline. I did some test on Bruno and the API was working fine but when i try with my program on Jakarta EE 10 i have an issue.
My aim is to run a pipeline throught gitlab API using specifif variables, so i create a request following this.
I set up my path https://mygitlab/api/v4/projects/:id/pipeline?ref=branch
and my variables, when I Sysout the body of my HTTP Post Request
{
"variables": [
{
"key": "foo",
"value": "bar"
},
{
"key": "alice",
"value": "bob"
},
{
"key": "key",
"value": "value"
}
]
}
And when i invoke my HTTP Post request i have this error with a code 400
{“error”:”variables[0][key] is invalid, variables[1][key] is invalid, variables[2][key] is invalid, variables[3][key] is invalid, variables[0][value] is invalid, variables[1][value] is invalid, variables[2][value] is invalid, variables[3][value] is invalid”}
I tried to launch the request with the same body on a postman like and it works so i expect that my problem come from Java or my wa to launch the request
Here is my code where i launch the request
buildJson.add("variables",arrayBuilder);
jsonObj = buildJson.build();
//Test
System.out.println(target.getUri());
System.out.println(jsonObj.toString());
//Test
Builder bob= target.request(MediaType.APPLICATION_JSON).header("PRIVATE-TOKEN", token);
Response response = bob.post(Entity.json(jsonObj));
Esteban Fernandes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.