https://github.com/npdeehan/rest-error-to-bpmn-error
This example show how you can trigger a BPMN error if you done get the response you're expecting from a REST API that
https://github.com/npdeehan/rest-error-to-bpmn-error
Last synced: about 1 year ago
JSON representation
This example show how you can trigger a BPMN error if you done get the response you're expecting from a REST API that
- Host: GitHub
- URL: https://github.com/npdeehan/rest-error-to-bpmn-error
- Owner: NPDeehan
- License: apache-2.0
- Created: 2021-04-09T08:54:15.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-09T09:35:27.000Z (about 5 years ago)
- Last Synced: 2025-01-23T01:34:33.829Z (over 1 year ago)
- Language: Java
- Size: 77.1 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# REST Error to BPMN Error Example
This example show how you can trigger a BPMN error in Camunda if you don't get the response you're expecting from a REST API that
## The Process
The process take an owner and reponame and tries to make a rest call to git hub to find the repo. By default the values are
``repoOwner = octocat``
``repoName = hello-world``
It will make the following rest call
``https://api.github.com/repos/octocat/hello-world``
![model]
If the response is 200 OK the process will continue the `Show Repo Details` task any other request type will trigger a BPMN error that move the process to the `Show Error` task.
## The Code
A java delegate will make the rest call
```Java
Unirest.setTimeouts(0, 0);
HttpResponse response = Unirest.get("https://api.github.com/repos/" + repoOwner + "/" + repoName)
.asString();
```
It will then check the response and throw an error if anything but a 200 is returned
```Java
if(response.getStatus() != 200){
throw new BpmnError("NO_REPO_FOUND", "Error making call - Repose Code: "+response.getStatus());
}else{
execution.setVariable("repoResponse", response.getStatusText());
}
```
[model]: ./src/main/resources/static/img/process.png