Part #1: Get Started
Introduction
This tutorial is based on [Project Template] Pakai Server v4.
Installation
GET
Introduction
This tutorial is based on [Project Template] Pakai Server v4.
Installation
- Download and put the following files to Additional Libraries folder
B4J:
- Pakai Server (4.00).b4xtemplate
- WebApiUtils.b4xlib (v4.70)
B4X:
- MiniORMUtils.b4xlib (v3.30) - If you want to use MySQL database, ensure you also have MySQL jdbc driver inside your B4J Additional Libraries folder.
e.g mysql-connector-java-5.1.49
- Once all the required libraries and template are in place, you can start B4J IDE.
- Select from File menu, New, Pakai Server (4.xx)
- Enter the name of your project as you like. Then click OK.
- Now the project is ready to run as it is.
- Click menu Project, Compile & Run (F5) or the play button on the toolbar.
- Hover you mouse pointer to the AppStart sub and click on the highlighted link to open the app on your web browser.
- The browser will open and load the index page.
It is a CRUD web application where you can add a new product (Create), search for a product (Read), edit an existing product (Update) and delete a product (Delete). - It has already generated some common APIs following the RESTful API principal.
To see the list of APIs, click the API link with a gear icon on top navigation bar.
- You will be redirected to the API documentation page.
You will see there are endpoints such as GET, POST, PUT and DELETE which are represented in different colours.
- You can click on any item to expand the section.
GET
- Click on the first end point name GET Read all Categories
- Click on the green Submit button.
- The form will send an AJAX request to the API server and return a JSON response (Code 200 for Success).
- To test a POST end point, click the third item with labeled POST /api/categories.
- Edit the content inside the Body text area, i.e value of the category_name in the illustration and click the purple Submit button.
Last edited: