Integrating camunda REST API in my spring boot application and access all functionalities from my application

Hi all, I’m new to camunda and I want to integrate camunda REST API in my own spring boot application. Below the details of my application properties file:

#Security properties
security.basic.enabled=false

server.port=8081

server.context-path=/api

#Database
db.driver: com.mysql.jdbc.Driver
db.url: jdbc:mysql://localhost:3306/dbname?useUnicode=true&characterEncoding=UTF-8
db.username: root
db.password: root

#Hibernate
hibernate.dialect: org.hibernate.dialect.MySQL5Dialect
hibernate.show_sql: true
hibernate.hbm2ddl.auto: update

#camunda configuration
camunda.bpm.history-level=audit
camunda.bpm.process-engine-name=CamundaProcessEngineConfiguration
camunda.bpm.jpa.enabled=true

Here is my build.gradle dependency:

compile group: ‘org.camunda.bpm’, name: ‘camunda-engine’, version: ‘7.6.0’
compile group: ‘org.camunda.bpm’, name: ‘camunda-engine-spring’, version: ‘7.6.0’
compile group: ‘org.camunda.bpm’, name: ‘camunda-engine-rest’, version: ‘7.6.0’
compile group: ‘org.jboss.resteasy’, name: ‘resteasy-jaxrs’, version: ‘3.1.2.Final’
compile group: ‘org.camunda.bpm.extension.springboot’, name: ‘camunda-bpm-spring-boot-starter-rest’, version: ‘2.0.0’

How can I implement camunda REST API and how I access it from postman.

1 Like

Do you use the camunda spring boot starter? If so, you should be able to activate rest by just adding the camunda-bpm-starter-rest dependency to your project.

1 Like

@jangalinski thanks for your reply. Deleted other dependencies. And run as springboot application now I don’t know how to access the camunda REST API via postman. I tried http://localhost:8081/api/engine is that correct?

1 Like

try http://localhost:8081/rest/engine

3 Likes

thanks it’s working. can you tell me how to add process engine in spring boot.

I would suggest you start by reading the documentation and exploring some of the examples …

yeah now only seeing your examples thanks.

Hi all, how Rest API can be extended?
I need to add additional endpoints to existing resource interfaces and/or override already implemented ones

Thanks in advance!

You can find a lot of useful information in this topic: How to add custom Rest Endpoints to Shared Engine?

I’m sorry but it wasn’t useful

I solved in this way:

Using camunda-bpm-spring-boot-starter-rest it will set up a default Rest API service
which you can’t change, so you don’t need to define it but just provide your CamundaJerseyResourceConfig and CamundaBpmRestJerseyAutoConfiguration as new Rest API service implementation extending the default class

Following an example:
CamundaBpmRestJerseyAutoConfiguration

@AutoConfigureBefore({JerseyAutoConfiguration.class})
@AutoConfigureAfter({CamundaBpmAutoConfiguration.class})
public class CamundaBpmRestJerseyAutoConfiguration
{
  @Bean
  @ConditionalOnMissingBean({CamundaJerseyResourceConfig.class})
  public CamundaJerseyResourceConfig createRestConfig()
  {
    return new CamundaJerseyResourceConfig();
  }
}

CamundaJerseyResourceConfig:

@Component
@ApplicationPath("/rest")
public class CamundaJerseyResourceConfig extends ResourceConfig implements InitializingBean {
	private static final Logger log = LoggerFactory.getLogger(CamundaJerseyResourceConfig.class);

	public void afterPropertiesSet() throws Exception {
		registerCamundaRestResources();
		registerAdditionalResources();
	}

	protected void registerCamundaRestResources() {
		log.info("Configuring camunda rest api.");
		registerClasses(NamedProcessEngineRestServiceImpl.class);
		registerClasses(CustomProcessEngineRestServiceImpl.class);

		// registerClasses(CamundaRestResources.getResourceClasses());
		registerClasses(CamundaRestResources.getConfigurationClasses());
		register(JacksonFeature.class);

		log.info("Finished configuring camunda rest api.");
	}

	protected void registerAdditionalResources() {
	}
}

As you can see I registered a CustomProcessEngineRestServiceImpl class as my new Rest API service implementation just overriding DefaultProcessEngineRestServiceImpl and registering your custom Rest service implementation (e.g TaskRestService)

For example I extended the TaskRestService with this steps:

  1. Extend TaskResourceImpl as CustomTaskRestServiceImpl to override a specific method (eg. claim, complete) or adding a new endpoint method

  2. Register your custom TaskRestService implementation subclassing DefaultProcessEngineRestServiceImpl as custom Rest API service

    public class CustomProcessEngineRestServiceImpl extends DefaultProcessEngineRestServiceImpl {
    
     @Path(TaskRestService.PATH)
     public TaskRestService getTaskRestService() {
     	CustomTaskRestServiceImpl subResource = new CustomTaskRestServiceImpl (null, getObjectMapper());
     	return subResource;
     }
    

    }

I hope was helpful :wink:
Best regards
Antonio

3 Likes

I also included

org.camunda.bpm.extension camunda-bpm-spring-boot-starter-rest 1.3.0

But getting this error – class path resource [org/camunda/bpm/engine/spring/SpringProcessEngineServicesConfiguration.class] cannot be opened because it does not exist

You have to carefully check which camunda, which spring boot and which camunda-bpm-starter version you are using.
Due to rapidly changing spring boot infrastructure, some strict constraints apply.

Find the matrix here: https://docs.camunda.org/manual/latest/user-guide/spring-boot-integration/version-compatibility/

Hello , sorry to answer on an old topic but my question is the following :

Does the /engine/rest endpoint provides the endpoints defined here ? :

https://docs.camunda.org/manual/7.7/reference/rest/

I tried with the same endpoint but i’m getting a 404 not found.

Thanks.

hi @nhafsaoui, The url to acess the camunda rest api in spring is /rest
example: http://localhost:8080/rest/user

1 Like

If none of the above URLs work for you, then try:

http://localhost:{PORT}/engine-rest/{method}

e.g. http://localhost:8080/engine-rest/incident