We need to startup jAgent and verify it's running. We can do that using the command jbase_agent
. You should see the following messages appear:
(25|25) NOTICE starting up jAgent, Process Per Connection mode, listening on port 20002
(25|25) NOTICE Configured using config file located in [/jbasedata/global/config/jagent_config]
Fire up your favortie browser and navigate to: http://localhost:20002/api/wresttest. This will prove that jAgent is up and running if you see a page full of JSON. It will also setup the WDB.RESOURCE file when it’s accessed for the first time.
Return to your command line window and you should see the following message:
(27|27) NOTICE RequestHandlerService::open: connected with 172.17.0.1
(27|27) NOTICE Shutting down Connection
Hit control+c to exit jAgent
The next step is to write a program that outputs JSON for the web. I have prepared a minimal program available here.
EDIT BP GET-API-DEMO
+ enterI
+ enter- Paste in the prepared program
- enter + enter
FI
+ enterBASIC BP GET-API-DEMO
+ enterCATALOG BP GET-API-DEMO
+ enter
Next, we need to wire up jAgent to our new program
EDIT WDB.RESOURCE API*DEMO
+ enterI
+ enterP
+ enterAPI FOR GETTING A SINGLE RECORD FROM DEMO-FILE
+ enterGET-API-DEMO
+ enter- space + enter
1
+ enter1
+ enter- enter + enter
FI
+ enter
To verify that it is working, first start up jAgent again with the command jbase_agent
. Then go back to your browser and navigate to: http://localhost:20002/api/demo/001
This will get us the data in JSON format that is accessible on the web.
I like to use a product called postman. Download it for free here: https://www.postman.com.
- Launch Postman
- Click the orange NEW button in the upper left-hand corner
- Select REQUEST, Name the REQUEST: DEMO GET SINGLE RECORD
- Select DEMO (last item on the lower left-hand side) for the collection
- Click SAVE TO DEMO button in lower right-hand corner
- In the center upper third of the next screen of the URL field type: http://localhost:20002/api/demo/001
- click SEND
You should now see the same output that we received using the browser This proves it worked and that this data is available to the UI layer to be built in our next video.
Copyright (c) 2020-present, Zumasys