How to get the currrent device type from a published rest service

0
Hi All,    We are publishing a rest service that redirects the end user to a certain URL, but we need to know the device type that is used by the user could be Desktop or tablet in order to specify the redirect URL.   Using $currentDeviceType is not avaiable in a published service.   Any ideas??
asked
2 answers
1

You could redirect them to a Deeplink from your REST service. This microflow would have the $currentDeviceType exposed, and you could redirect them from there to the correct page.

 

Good luck!

answered
0

In Mendix, the $currentDeviceType context variable is typically used in client-side logic, and as you mentioned, it's not directly available in a published REST service. However, you can work around this limitation by including the device type as a parameter in your REST service.

Here's a simple approach:

  1. Include Device Type as a Parameter:

    • When you call the REST service, include a parameter indicating the device type. You can pass this parameter in the request URL or as a request header.
  2. Retrieve Device Type in a Microflow:

    • In your microflow (which is called by the REST service), retrieve the device type from the incoming request parameters or headers.
  3. Specify Redirect URL Based on Device Type:

    • Use an exclusive split or conditional logic in your microflow to determine the device type and specify the redirect URL accordingly.
answered