Step 1: Open OutSystems application (if you know Arch. Layer than follow that) and go to logic tabStep 2: Right click on the REST and select the Expose REST APIStep 3: It will create REST API, but you need to add method in that so again right click on the API like below screen short
Step 4: In that you can right the logic, what ever you need. Example: I have created a "Create Community Action" in which I have written the code. (I have also show the exception Errors)
Step 5: In above screenshot, If you see there are the one server action namely “SetStatusCode” used to show the code in the output Ex:400 (bad request),404(not found),500(server down))
Step 6: To authenticate your API while consuming, there is three authentication property you can change as per below screenshot1) None: no authentication request (Default)2) Basic: when consuming required register role credential(username, password) of OutSystems3)Custom: You can able to write customized logic for this and whatever logic you write it will need to be authenticate while consumingStep 7: Publish your application. After that, to get the URL and body, right-click on the Rest API and click on the open documentation. It will open the documentation in browser and in that you are able to see all the method inside that API as below
If you click on the method it will give you the required thing to consuming the APIStep 8 (consuming API): using the above information, request URL, body I am consuming API in postman you can be able do the same thing in OutSystems as wellTo show the server error, I have to pass 500 ranks forcefully so that it will show the exception error and result. If you see 500 Internal server error to get that code we need to follow step 5 if you not write that code than it will show 200 OK every time which is wrongTo show successful record I have create the record on postman and to check it is working on not I created one screen to show the list of record which I create (check Below screenshot)For more understanding go through the application are do same in your applicationI have created for action- Create community- Delete All- Delete community record (need rank to delete single record)- Update community