First time poster.....
I've been tasked with reviewing our Mendix app, which integrates heavily with a custom REST API.
I see the following pattern over and over and wonder if it is possible to parameterize:
1. Retrieve access token(s). (We are using a 3rd party auth service)
2. Make REST call
3. Generic error/response handling (e.g. if token expired error, need to refresh access token and retry request)
Parts 1 and 3 are the same for all requests and part 2 can change. As far as passing parameters into microflows goes, it doesn't look like it is possible to parameterize:
- HTTP method to use
- Import mapping to use
- Request content (in case of POST/PATCH)
The best I've been able to do is created repeated microflows of 3 actions for each endpoint. I am considering a custom Java action for the call, but wondered if there was a way to achieve it in the modeler?
Can't you just create a submicroflow for the call that has different REST call actions depending on the data passed? That would be my first Idea
You can parameterize these if you use the REST module instead of the native REST calls in Mendix.
Otherwise the answer of Andreas Blaesius is the best way to go.
If you're looking to make these calls more generic, I think a little bit of Java exposed as a microflow action is probably the way to go. Java actions can be defined with input parameters for each of the values you need:
Once you're done, you can expose this Java action as a microflow action so other developers can easily find and use it.
If I understand correctly, that would mean doing something like the image below. This seems awfully painful to maintain for a large number of endpoints. I was wondering if there was a way to parameterize those variables I mentioned, but it seems not.