SAPODataConnector - Handle csrf/cookie without user session
in line with the idea posted by Fabian (https://forum.mendix.com/link/ideas/602) we are running into a scenario where we want to make an SAP Post through a process queue. With the current implementation of the SAPODataConnector handling of CSRF Tokens and Cookies is tied to the current user (and current user session). This automatically means, that it is not possible to use any of the OData methods that require CSRF tokens out of the box in a ScheduledEvent/ProcessQueue or any other process running in a system context. To properly implement interfacing solutions not running in as user context it is required that the module handles this correctly in a system context.
Han Pieter Duyverman
Hi Han Pieter,
You can use the CommunityCommons.executeMicroflowAsUser_ x to simulate a queued action as if it was in a user context. In this Java action you can specify a ‘performing’ (local system) user, the microflow that you want to run, and at least 1 input parameter that is needed to perform the microflow. You will then be able to fetch your required CSRF token and session ID cookie which are needed for the POST.
as far as I remember the latest Connector was also able to handle CSRF Tokens in a server context. But the token is only stored within the execution context of the microflow (it’s not persisted).