Credits to Chris Malek (his article is a must read) for showing us the way. Most of the API is still undocumented, but you can make use of PeopleCode Auto-completion feature to explore the API methods and properties. It seems a lot has been borrowed from Groovy. A good place to start is the delivered ES App Pkg - PTSF_ES:*. I also went ahead and created a sample python script for the same REST end point. Python makes your life a lot easier. Let's have a look at a sample in PeopleCode first.
I will break it down into steps for easier understanding:
- Make a GET request on a given REST end point. It is easier to bypass the Integration Engine and make use of IB ConnectorRequest to initiate the sync request.
- Instantiate a JSONParser and read the response JSON;
- Read the JSONArray and retrieve the Property and print the values;
|IB Connector Request|
Use the parser object and retrieve the Root Object. Check for key "RestResponse", and read the return array.
Credits to Cameron Barre for sharing his JSON encoding library