I have problem with calling TaskList and Operate APi using FeingClient.
My Feign class
@FeignClient(value = "operate-client", url = "${api.operateUrl}", configuration = OperateClientConfiguration.class)
public interface OperateClient {
@RequestMapping(method = RequestMethod.GET, value = "/v1/process-instances/{key}", consumes = "application/json", produces = "application/json")
ProcessInstance getProcessInstance(@PathVariable Long key);
@RequestMapping(method = RequestMethod.POST, value = "/v1/process-instances/search", consumes = "application/json", produces = "application/json")
ProcessInstance getProcessInstances();
}
Config Feign class
@Configuration
@RequiredArgsConstructor
public class OperateClientConfiguration {
private final TaskAdapterConfiguration taskAdapterConfiguration;
@Bean
public RequestInterceptor operateBearerTokenRequestInterceptor() {
return template -> template.header("Authorization",
String.format("Bearer %s", TaskAdapterBeanConfig.getToken(
taskAdapterConfiguration.getLoginUrl(),
taskAdapterConfiguration.getOperateClientId(),
taskAdapterConfiguration.getOperateClientSecret(),
TaskAdapterBeanConfig.AUDIENCE_OPERATE).getAccessToken()));
}
}
I use credensials from operateAPI and they work fine
public ProcessInstance getProcessInstance(Long processInstanceKey) throws UnirestException, IOException {
BearerToken operateToken = getToken(taskAdapterConfiguration.getLoginUrl(), taskAdapterConfiguration.getOperateClientId(), taskAdapterConfiguration.getOperateClientSecret(), AUDIENCE_OPERATE);
String response = Unirest.get(taskAdapterConfiguration.getOperateUrl() + processInstanceKey)
.header("Accept", "application/json")
.header("Authorization", "Bearer " + operateToken.getAccessToken())
.asJson()
.getBody()
.toString();
return mapper.readValue(response, ProcessInstance.class);
}
What I’m missing?
Hi @Darek_Krystian
You just mentioned that for operateAPI the credentials work fine. What is the problem with TaskList?
Regards,
Alex
Hi,
When I use that Feign client I recive this error
feign.FeignException$BadRequest: [400 Bad Request] during [GET] to [https://bru-2.tasklist.camunda.io/{myClusterId}/v1/forms/OverrideClientForm?processDefinitionKey=2251799814748289] [TaskListClient#getForm(String,String,Long)]: [<html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx</center>
</body>
</html>
]
at feign.FeignException.clientErrorStatus(FeignException.java:222) ~[feign-core-13.2.1.jar:na]
at feign.FeignException.errorStatus(FeignException.java:203) ~[feign-core-13.2.1.jar:na]
at feign.FeignException.errorStatus(FeignException.java:194) ~[feign-core-13.2.1.jar:na]
at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:103) ~[feign-core-13.2.1.jar:na]
at feign.InvocationContext.decodeError(InvocationContext.java:126) ~[feign-core-13.2.1.jar:na]
at feign.InvocationContext.proceed(InvocationContext.java:72) ~[feign-core-13.2.1.jar:na]
at feign.ResponseHandler.handleResponse(ResponseHandler.java:63) ~[feign-core-13.2.1.jar:na]
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:114) ~[feign-core-13.2.1.jar:na]
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:70) ~[feign-core-13.2.1.jar:na]
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:99) ~[feign-core-13.2.1.jar:na]
at jdk.proxy2/jdk.proxy2.$Proxy107.getForm(Unknown Source) ~[na:na]
I had same error when I try to call any of endpoints in operate API with proper Feign and config
I ended using CamundaTaskListClient from
<dependency>
<groupId>io.camunda</groupId>
<artifactId>camunda-tasklist-client-java</artifactId>
<version>8.4.0.7</version>
</dependency>
Regards,
Darek
Hi @Darek_Krystian, welcome to the forums! The path /v1/forms/OverrideClientForm
isn’t a valid Tasklist API endpoint, so I suspect that’s why you’re getting a 400 error. Where did you get that path from? You can see all the available Tasklist endpoints here: Tasklist REST API | Camunda 8 Docs
I passed it as param in, its my Form id
Screenshot is from camunda TaskList swagger
Regards,
Darek
@Darek_Krystian - oh my, I completely misread that! Apologies! It seems to work in Swagger; have you tried Postman (or similar REST client) to test the call? It would seem the issue might be the FeignClient. Unfortunately I’ve never used it so I can’t offer any advice in configuring it.