Hi All,
I have a task where we pass the below data as input and output parameters. Please help me understand how we implement this using. REST API
Hi @Akshata Tallur
You just need to go to logic tab. There is option Integrations->Rest.
Right click on it and choose expose API. Then add one API method in REST API. Once method is there you can add API's Input and Output parameters. It will be same like we do for a normal server action. Please refer below screenshot and let me know if still you have some doubt.
regards
Hi Vikas,
I need to use post method and pass that input as tallur and get the output as mentioned in above image
Apporach will be same, you just need to choose post from the properties pane of the action. Then can define the output parameters for the output mentioned.
Hi @Akshata Tallur ,
You can expose this as a POST REST API using request and response structures.
Structures are recommended because POST data is normally sent as JSON in the request body. OutSystems automatically converts the JSON into the request structure and the response structure back into JSON.
As for the action logic:
I used Regex_Replace and String_Split to convert the input into a list of individual characters. The action then loops through the list, counts each character while keeping uppercase and lowercase values separate, and stores the results in a local list. Finally, it loops through the counted characters, reverses their case, and builds the formatted API response.
Make sure to change the base url of the consuming API with yours.
Result:
Hi @Mihai Melencu
I am getting below error while testing
You need to update the BaseURL of the consuming API to match your infrastructure url.
Based on the image you shared, the new base URL should be https://akshata-tallur.outsystemscloud.com/RestAPISample/rest/CharacterCountAPI .
I updated it and shared the OML as well.
@Akshata Tallur : If you are overwhelmed with loops and conditions in OutSystems, create an extension instead. A single line using LINQ can replace complex flow logic:
string.Join(",", ssInput.GroupBy(c => c).Select(g => $"{g.Key}={g.Count()}"))
This groups characters, counts occurrences, and joins results.
Note : if you want case insensitive count ,change the code to ssInput.ToLower().GroupBy or if you want to remove space - ssInput.ToLower().Replace(" ", "").GroupBy etc.