visit
About Linx
Linx is a general-purpose low-code platform for building and hosting backends. Developers design and debug solutions in a familiar procedural style using a drag-and-drop interface with access to 1000s of ready-made functions. Solutions are deployed with one click to servers running in the cloud or on-premise. Further reading: .
1. In the Linx Designer, create a new solution. Add the by clicking on the ‘ADD PLUGINS’ button within the Plugins Panel.
2. Add a service to your solution by dragging the SimpleRESTHost component from the Plugins tab, onto the central canvas.
3. Set the Base URI property (under the API definition property) to //localhost:5000. Save the Solution.
4. To create the events that will act as endpoints, you first need to make the custom type that will be returned. This custom type will be returned as a JSON object when the endpoint is called. To create this custom type click on the Solution ribbon, and click on the Import Type option.
Paste the below JSON into the dialogue box. Name the type of Product then click the create button
[ { "id": 0, "name": "string", "price": 0, "quantityInStock": 0 } ]
5. You can now create the events that will function as the endpoints of the API. Select the SimpleRESTHost, then click on the ellipses next to the Operations setting.
6. To create the GetAllProcucts event do the following:
I. A default operation will exist in the operation list. Change the name to GetAllProcucts
ii. Set the path to be /products
iii. Set the response body to be a list of the Product type that was created in step 3. To do this click on the dropdown on the response body, select List, then click on the edit button and select Product under the solution section
7. To create the GetProductByID event do the following
ii. Set the name to GetProductByID
iii. Set the path to be /productByID
8. For the getAllProducts event:
ii. Select the GetAllProducts event by clicking on it.
iv. Create a new for the database connection string. A setting can be created by clicking on the Settings icon and then adding the new setting to the grid. Call the setting DB_Connection and set its value to:
Server=postmandb.twenty57.net;Database=postmanTemplate;User Id=Guest_User;Password=DwVHXx!sVeA9x52Mhus6Vfg?;
v. Set the connection string in the ExecuteSQL function to the DB_Connection setting created above. It will then contain the value: $.Settings.DB_Connection
SELECT id ,name ,price ,quantityInStock FROM dbo.Products;
vii. Set the return options of the ExecuteSQL function to ‘List of rows’
viii. Add a Return function to the event underneath the ExecuteSQL function.
Steps VI to IX set the response of the event to be the list of products returned by the ExecuteSQL function.
9. For the GetProductByID event:
SELECT id ,name ,price ,quantityInStock FROM dbo.Products WHERE Id = @{$.Parameters.id}
10. the Simple REST Host service. Do this by selecting the SimpleRESTHost, and then clicking on the Debug button. When the debugger is ready, click on the Start button. This will start the service in a locally hosted instance for testing. When done the debug output should have a message that reads: ‘SimpleRESTHost service started.’
11. Test the getAllProducts event. Do this by calling the below URL in any browser when the SimpleRESTHost service has started in debug mode:
//localhost:5000/products
Note that the response body is a JSON object list that contains all products in the database table.
12. Test the GetProductByID event. Do this by calling the below URL in any browser when the SimpleRESTHost service has started in debug mode:
//localhost:5000/productByID?id=1
13. In the Linx Designer, select the ProductAPI RESTHost service, change the BaseURI from //localhost:5000
to //+:8080
14. Set the API Documentation to Swagger UI. This will allow the server to host Swagger UI documentation for our API.
15. Rename the solution to QuickProductAPI. Do this by clicking on the solution in the solution explorer and then changing the name property then saving the solution. This is important because it will reflect as such on the Linx Server. Renaming it will make the solution easier to identify when you have more than one solution deployed.
16. Now that the API is developed and final changes are made, it is time to deploy it to a server where it will be hosted.
About the Linx Server:
The Server is a Windows Service that hosts and manages your Linx Solutions and web services. You can install Linx Server on the hardware of your choice (on-premise or cloud) with monitoring, metrics, and logging as standard. Further reading: .
17. When you open the Server, and the solution is uploaded and ready to use, it should look like this:
18. Click on the ProductAPI Solution, and then turn the RestHost service on
19. Swagger documentation is hosted on the server and is accessible via any browser. You can access this by accessing the hosted API URL. The Hosted API URL is your server name ‘[my-domain].api.linx.twenty57.net‘. Add ‘/swagger’ to access the swagger documentation. The address will look similar to this:
//xxxxxx11.api.linx.twenty57.net/swagger
In this section, you will test the hosted API. This can be done by using any API testing tool such as Postman, hoppscotch.io or even a web browser. To call the API, the Linx Server is set up in such a way that your API is hosted at your server name ‘[my-domain].api.linx.twenty57.net‘. Add the endpoint paths behind this hosted address to call the endpoint.
20. Test getAllProducts. Do this by calling the below URL modified with your server name (replace the xxxxxx11 with your server name) in any browser (or testing tool):
//xxxxxx11.api.linx.twenty57.net/products
21. Test GetProductByID. Do this by calling the below URL modified with your server name (replace the xxxxxx11 with your server name) in any browser (or testing tool):
//xxxxxx11.api.linx.twenty57.net/productByID?id=1
22. Call the GetProductByID endpoint with id = -1 at least once, this will force an internal server error. This will allow you to see how Linx Server displayed errors.
//xxxxxx11.api.linx.twenty57.net/productByID?id=-1
23. Open the solution to view the events and errors in the dashboard. To view errors, click on the red indicator on the dashboard. Alternatively, click on Log to view displayed errors.