How is your experience with the OutSystems Community?
25
Views
7
Comments
Expose rest api
Question

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 

UserImage.jpg
vikas sharma
Champion

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

2023-12-07 13-05-35
Akshata Tallur

Hi Vikas,


I need to use post method and pass that input as tallur and get the output as mentioned in above image

UserImage.jpg
vikas sharma
Champion

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. 

2026-01-28 16-57-48
Mihai Melencu
Champion

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:


RestAPISampleCount.oml
2023-12-07 13-05-35
Akshata Tallur

Hi @Mihai Melencu 

I am getting below error while testing 

2026-01-28 16-57-48
Mihai Melencu
Champion

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.

RestAPISample_updated.oml
2019-01-07 16-04-16
Siya
 
MVP

@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.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.