using POST to login to a webserver using REST api in mendix
I am trying to login to an external webserver using a mendix REST microflow but cannot find a good example or documentation that is helpful. Here is what I am trying to do. register a user on an external webserver use a username and password to login to that external webserver get a return token, save it and use it in the subsequent calls Please give me some pointers for this example.
It seems like you will have to use custom HTTP headers for your REST calls including the initial authentication POST call. Take a look at the information in this forum question – https://forum.mendix.com/link/questions/91485, it has the OAuth authentication token handling.
Basically, you will see from the example above that once you have accessed the authentication token from the POST response header, you could store it in an entity associated with your Account and retrieve it for subsequent REST calls. If you decide to store it in a persistent entity, it will probably require some delete behavior to clean up this entity whenever the session gets removed.
Alternatively, you could create a non-persistent entity to store the token and associate it directly to the session object. Session object is available in microflows as variable $CurrentSession and you could always retrieve the token from it for your subsequent REST calls.