Configuring exposed microflow paths using the RestServices module - Mendix Forum

Configuring exposed microflow paths using the RestServices module

0

Hi All,

I'm using the RestServices module v 3.2.0 in my app and attempting to expose the microflow "MyModule.Microflow" with a wild card path. When I expose the microflow without specifying a path, as below, I can reach it in my local environment by making HTTP calls to http://localhost:8080/rest/microflow.

However, when I try to set the wild card path as below, I get an error messages saying the service can't be found.

Any ideas how I can set up the required path?

asked
2 answers
0

The CreateMicroflowServiceWithPath microflow's PathTemplate parameter should be in the form of a regular expression. The solution is to set the PathTemplate parameter to "microflow/.{0,}". The dot (.) token in the regular expression matches any character, and the "{0,}" matches 0 or more of the preceding token. 

So with this regular expression set in the PathTemplate, calls to "http://localhost:8080/microflow/", "http://localhost:8080/microflow/foo_bar", etc. will route to the same exposed microflow.

answered
0

Hi Steven,

Have you seen the documentation on github?

It is possible to provide a template path when registering a microflow service. This allows for constructing more complex URLs, from which values are parsed. For example, a microflow could be defined with the template path: groups/{groupId}/users/{userId}. If that service would be called with http://myapp.com/rest/groups/123/users/John, the attribute groupId of the input argument of the microflow would be instantiated with the value 123. Likewise, the attribute userId would be instantiated with the value John.

 

I think you would need a path of /microflow/{microflowname} and in your microflow that you are exposing have a parameter called "microflowname"

 

Here is a link to the github. There is also a test project that you can check out. 

https://github.com/mendix/RestServices

 

Hope this helps!

 

Edit: Sorry I confused the newer publish rest services with this one. For this path to work 

/microflow/{microflowname}

 

The microflow that you are exposing needs to have a parameter of an non-persistent object with an attribute called "microflowname". Then when you call your service, this object will be passed to the microflow with the attribute value set based on what was sent through the url.

 

Edit 2: I think a request handler can solve your issue. Here is a link to a really good blog post.

https://www.mendix.com/blog/requesthandlers-at-your-service/

I'm not too sure what you are trying to accomplish but you could setup a request handler as your catch all and then call your microflow service. 

answered