can anyone tell me the steps to put a REST API on button. For example i have a login API and instead of outsystems login action i want my login api to work.  

Easier way:

1. Consume your api

2. In the Login action of the Login page, call your api login method passing the user and credentials. 

Remember that if you don't login also in OutSystems, you will be navigating as anonymous. 

Hi Eduardo,

Thanks a lot for your help. I am just stuck at one step. What to expression do i need to enter in postLoginRequest(The request parameter of post login). Have a look at the attachment.

Eduardo Jauch wrote:

Easier way:

1. Consume your api

2. In the Login action of the Login page, call your api login method passing the user and credentials. 

Remember that if you don't login also in OutSystems, you will be navigating as anonymous. 

Ok so this means the credentials have to be there in both the databases that is my external and outsystems both?


Hi Avneet,

1. Doesn't have the slightest idea. This is an API method. You have to consult the documentation of this method in the API docs to see what you need to pass.

2. Not necessarily. The Login action from System does not need the credentials. Just the password. So, you need to keep a user in the User table, but you don't need to store its credentials.

Cheers.

Eduardo Jauch wrote:

Hi Avneet,

1. Doesn't have the slightest idea. This is an API method. You have to consult the documentation of this method in the API docs to see what you need to pass.

2. Not necessarily. The Login action from System does not need the credentials. Just the password. So, you need to keep a user in the User table, but you don't need to store its credentials.

Cheers.

Hi Eduardo,

I am uploading my module. Please help me with this by taking a look at what i have done. and you can make the desired changes. and the problem I am facing is that i am unable to reach the homepage after a successful login.

Hi,

Sorry, can't change it.
But the problem is clear.

1. You call your method, but do not check if the result means the login in the API was successful.

2. You are NOT doing the login in the OutSystems using the Login action of System AFTER validating the login in the API was Ok. 

So, when you try to reach your page, you are going there as anonymous, and as the page requires a registered user (Login in OutSystems), the page refuses the request.

Fiz 1 and 2 and you probably will be good to go.

Cheers.

Eduardo Jauch wrote:

Hi,

Sorry, can't change it.
But the problem is clear.

1. You call your method, but do not check if the result means the login in the API was successful.

2. You are NOT doing the login in the OutSystems using the Login action of System AFTER validating the login in the API was Ok. 

So, when you try to reach your page, you are going there as anonymous, and as the page requires a registered user (Login in OutSystems), the page refuses the request.

Fiz 1 and 2 and you probably will be good to go.

Cheers.

ya its done. Is there any way to login without putting the outsystems login, so that i dont have to check the credentials from outsystems database, check them only in external database and i have the access to homepage.


Hi, 

As I stated before you can login using the Login action of the OutSystems, you will log in the user (id) without requiring credentials. So, you don't even need credentials stored in the OutSystems User entity.

You just check if the API returned that your user is logged and if so, you do the login in OutSystems (no need to credentials there).

Cheers.