Tuesday, February 14, 2017

Creating a Service Code Service Endpoint in Appery.IO

Appery.IO has a neat visual interface to create a REST API service (endpoint). There are two options for creating  a service. In the first option you can generate REST API automatically for a database table or a Custom REST API. In the former, you will be asked for a connection to a table. At present it appears that connecting to a named instance of SQL Server table is not possible.

In the following post, I describe creating a service endpoint using server side code for a Collection(similar to a table). The same interface can be used for creating service flow with advanced logic to include REST API, SOAP Services, Custom SQL Queries, etc. 

API Express create new project FFD



ApperyIO6_00

Note: I am not sure why there is a textbox below the Create New Project button as the following screen asks for the name of a New Project.

In the New project window enter the name.


ApperyIO6_01


New project is created. Click on SQLData in the project page to open the SQLData page as shown.



 ApperyIO6_02.PNG



Click new service in the screen above.

The New service page opens as shown.




ApperyIO6_03.PNG

Provide a Group name (JanSvc2_14) and choose Custom REST API and click create.



ApperyIO6_04.PNG

Drag and drop the Server Code (SC) from the PALETTE to the empty box as shown. If you want to remove it you click the red circle with x.



ApperyIO6_05.PNG

In the PROPERTIES -SERVER CODE click the handle and select the only script there -loadGoodsScript. For the Script Query Parameters click on the handle to reveal the following:

ApperyIO6_06.PNG

Choose BODY.

For SCRIPT BODY place check mark for Use previous component and click Generate.


ApperyIO6_07.png

Click Generate. Generate Service Response window opens.


ApperyIO6_08.PNG

Click Run Server Code API.
 
The code is run and the result is displayed as shown.


ApperyIO6_09.PNG

Click Import Response.


The Response is now in the visual designer.

ApperyIO6_10.PNG

Now you can test the API. Click TEST in the menu. The Service Test page is opened displaying the endpoint and a Test button as shown.


ApperyIO6_11.PNG

Click Test.
The Test succeeds otherwise there would be an error which you can debug by going to the Settings.

ApperyIO6_12.PNG

Copy the endpoint in the above and paste it to the address of a browser and you should see this.




Now you have a endpoint to work with.



No comments:

Post a Comment

SQL Server 2025 ready to go

 I have not yet done looking at SQL Server 2022, SQL Server 2025 is ready to go. Microsoft is indeed relentless!  Microsoft announced SQL Se...