I have a form with several fields that should save data on button click to an API.I am able to POST the information to the API using Postman and through the REST integration test in Outsystem.How do I go ahead and implement the button click action to save data to the API?
Ok, i understand.
if you have a REST API you are consuming with JSON body, how does it look like in Outsystems?
There should be a structure created for it. Not plain text.
Hi,
You need to create a Screen action where you will call the POST method (the best is to abstract the POST method call in a Server action in the integration module and then consume that server action).
Then, you need to assign the variables from your form to the input of the method call (or the server action).
This kind of usage is not straight forward because every API have their own particularities.
I advise you to check the documentation and videos about the usage of API methods:
https://www.youtube.com/watch?v=gNyWIeJYfG0
https://success.outsystems.com/Documentation/11/Extensibility_and_Integration/REST/Consume_REST_APIs/Consume_one_or_more_REST_API_methods
Hope this can help you.
Best regards,
Ricardo Pereira
This is my save screen actionAnd this is my server actionBut still am not able to POST to API
you said: "and through the REST integration test in Outsystem."
Then you know how to send the request right?
I am able to pass JSON data in the request body to the API.I want to replicate that using a button click on a web app now.I am sure am not far off for it to work> Am not sure what am missing though (-:
The normal way to go in Outsystem is that you create a server action that is a wrapper of the API method you are calling with the json.
You put a structure as input for that server action and cal that action from your button.
I don't see why you would want to solve your problem the way you propose. Do you have a specific reason to do it that way?
I have created a POST API call, created a server action with Authorization and request body similar to the API method (I actually copied the authorization and request from the API call),Called my server action in the button save screen action. I imagine this is the standard way? Is there anything I am missing? Might it be something to do with data types?
Can you share your oml?
The OML is quite huge with some sensitive info
Why don't you have the method in the flow? You will need it to call it, like this:
You can drag and drop it from your Integrations Folder (REST) section in Logic Tab.
hope this can help.
You create a server action that calls the Rest API you already tested, with the input you need for the API (could be a different structure, that's up to you).
In the save button action you can call that Server action with the information you got from the screen/form.
For more information on traditional web building:
https://success.outsystems.com/Documentation/11/Getting_started/Create_Your_First_Traditional_Web_App