CS API Service
CS API Service
CS API Service provides access to Control Service API methods from Automation Process under AP run group user credentials.
To use the service, you should inject CsClient object into the task.
@ApTaskEntry(name = "CsClient Task") @Slf4j public class CsClient extends ApTaskBase { @Inject CsClient csClient; }
Call API methods
The service provides row of methods to call REST API. Here is a code example to use the client:
pom.xml
<dependencies> . . . . <dependency> <groupId>eu.ibagroup</groupId> <artifactId>easy-rpa-be-communication</artifactId> <version>${rpaplatform.version}</version> </dependency> <dependency> <groupId>eu.ibagroup</groupId> <artifactId>easy-rpa-control-server-api</artifactId> <version>${rpaplatform.version}</version> </dependency> . . . . <dependencies>
Where the imported dependencies contains Control Server API DTO objects to serialiaze/deserialize JSONs.
CsApiTask.java
package eu.ibagroup.easyrpa.tests.task; import eu.ibagroup.easyrpa.cs.controller.dto.AutomationProcessRunDto; import eu.ibagroup.easyrpa.cs.controller.dto.UserDto; import eu.ibagroup.easyrpa.engine.annotation.ApTaskEntry; import eu.ibagroup.easyrpa.engine.apflow.ApTask; import eu.ibagroup.easyrpa.engine.cs.api.CsClient; import lombok.extern.slf4j.Slf4j; import javax.inject.Inject; @ApTaskEntry(name = "CsApiTask") @Slf4j public class CsApiTask extends ApTask { @Inject private CsClient csClient; @Override public void execute() throws Exception { UserDto userDto = csClient.getJson("users/currentuser", UserDto.class); log.info("Current user {}", userDto); AutomationProcessRunDto run = csClient.postJson("automation_processes/1000/runs", null, AutomationProcessRunDto.class); log.info("Run started {}", run); } }