Making REST API call in camunda platform 8 self-Managed

Hi Team,
Iam Facing issue while working with connectors in camunda 8 self managed, Making an REST API call.
1.In desktop modeler using element-templates i congifured REST Connector in bpmn.

{
“$schema”: “https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json”,
“name”: “REST Connector”,
“id”: “io.camunda.examples.RestConnector”,
“description”: “A REST API invocation task.”,
“appliesTo”: [
“bpmn:ServiceTask”
],
“properties”: [
{
“type”: “Hidden”,
“value”: “http”,
“binding”: {
“type”: “zeebe:taskDefinition:type”
}
},
{
“label”: “REST Endpoint URL”,
“description”: “Specify the url of the REST API to talk to.”,
“type”: “String”,
“binding”: {
“type”: “zeebe:taskHeader”,
“key”: “url”
},
“constraints”: {
“notEmpty”: true,
“pattern”: {
“value”: “^https?://.*”,
“message”: “Must be http(s) URL.”
}
}
},
{
“label”: “REST Method”,
“description”: “Specify the HTTP method to use.”,
“type”: “Dropdown”,
“value”: “get”,
“choices”: [
{ “name”: “GET”, “value”: “get” },
{ “name”: “POST”, “value”: “post” },
{ “name”: “PATCH”, “value”: “patch” },
{ “name”: “DELETE”, “value”: “delete” }
],
“binding”: {
“type”: “zeebe:taskHeader”,
“key”: “method”
}
},
{
“label”: “Request Body”,
“description”: “Data to send to the endpoint.”,
“value”: “”,
“type”: “String”,
“optional”: true,
“binding”: {
“type”: “zeebe:input”,
“name”: “body”
}
},
{
“label”: “Result Variable”,
“description”: “Name of variable to store the response data in.”,
“value”: “response”,
“type”: “String”,
“optional”: true,
“binding”: {
“type”: “zeebe:output”,
“source”: “= body”
}
}
]
}

2.Making GET method with REST Endpoint URL “https://catfact.ninja/fact”.
3.Deploying the BPMN and started instance using java spring boot application.
4.But in operate process is stopped at REST call.

Need Help to process this forward @Ingo_Richtsmeier @Hafflgav.

Thanks in advance
ThanmaiChakka
Associate Software Engineer
Acheron Software Consultancy.

Same problem here.

Hi @ThanmaiChakka and @emailtowalter,

you have to run a job worker to execute the rest call.

You can clone this repository and start the spring boot application or use the docker image as described in the README.md: GitHub - camunda-community-hub/zeebe-http-worker: Zeebe worker for HTTP calls

Hope this helps, Ingo

1 Like

Hi @Ingo_Richtsmeier , Now iam facing issue while getting response from rest api.

url using : https://catfact.ninja/fact
REST-API-SelfManaged.bpmn (3.6 KB)


Not sure that iam doing mistake in element templete or in modeler properties.

can u check on this.

Hi @ThanmaiChakka,

the error message in Operate is given by the job worker.

You should have a closer look there.

Hope this helps, Ingo

Hi @Ingo_Richtsmeier
This is the error message
Error message : failed to evaluate expression ‘{response: body}’: no variable found for name ‘body’

Hi @ThanmaiChakka,

I checked your process model with the worker code from GitHub - camunda-community-hub/zeebe-http-worker: Zeebe worker for HTTP calls and it worked for me as expected.

I don’t know what you have changed that body isn’t picked up and mapped to response.

What I did:

  1. started the docker-compose-core.yaml from here: GitHub - camunda/camunda-platform: Camunda Platform 8
  2. Deployed your process from above to zeebe.
  3. cloned the worker and started it from eclipse.
  4. started a process instance with zbctl create instance rest-api-self-managed --insecure.
  5. checked the content of the user task in Tasklist.

Hope this helps, Ingo

2 Likes

Thank You @Ingo_Richtsmeier its working fine, Iam getting REST api response with code from GitHub - camunda-community-hub/zeebe-http-worker: Zeebe worker for HTTP calls by configuring “type” to zeebeWorker @ZeebeWorker(type=“http”,autoComplete = true).

1 Like

Hi @ThanmaiChakka

I followed your example and tried to figure out how camunda 8 and API request works.
I built my own job worker with nodeJS and right now I was able to make the API request using the URL parameter and fill in the return body parameter of the task.

In your last comment you describe the type “autoComplete=true”. I don’t know where you define this to make the process automatic. Can you share that setup?

Thanks in advance

Hello @Renzo
Happy to hear that…
It’s not mandatory to use autoComplete = true in @Zeebe Worker annotation, without that also job worker works Good, To know more about them please follow the link How to Write Glue Code without Java Delegates in Camunda Platform 8 - Camunda

Thanks & Regards,
Thanmai

1 Like

Hi @Renzo,

the @ZeebeWorker(type=“http”,autoComplete = true) is a feature of spring-zeebe, the client to package workers in a Java Spring-Boot application: GitHub - camunda-community-hub/spring-zeebe: Easily use the Zeebe Java Client in your Spring or Spring Boot projects

Hope this helps, Ingo

1 Like

@ThanmaiChakka and @Ingo_Richtsmeier

Thanks for your answer, it clarifies me about this approach.

I built my job-worker with “zeebe-node” library.

I use the “url” parameter to make the http request and return the body when the job completes.

This is my solution if you want to check.

1 Like