I am working on Consuming REST API in Mendix. I have consumed one login api from which i get the user’s details and access token. Once i logged in I need to call other rest api which required access token in headers. I know how to pass it in headers but i am not able to save the token as the rest api data is not persistable in my case.
How can i use System.Session? The Session entity is in System Domain Model. How can I access it in My Module(Domain Model)?
In microflows the session object is available as variable $CurrentSession. You can add an association between the session object and another object, which you can then retrieve with the variable.
Hope this helps?
“I know how to pass it in headers but i am not able to save the token as the rest api data is not persistable in my case.”
You will indeed like Sytze said, need to create a new object with a direct link to session storing the token. And whether you commit that or not is up to you. it doesn't really matter, you can just add some delete behavior between session and the new entity and it gets cleaned up whenever the session gets removed.