Using Xojo’s URLConnection to communicate with web services is pretty straightforward. But testing the actual REST API calls can get tricky. To make it easier to test and experiment with REST API calls, Paul created a app in Xojo for doing just this. He called it RESTy in its original format back in 2015. You can download the updated project here built with Xojo 2022r4.1.
RESTy uses the URLConnection class to send a request to a web service and get a result. If the result is text (JSON, for example) it displays in the Response tab. Here, I am calling the Eddie’s Electronics web service to return a list of all the customers by specifying the URL and clicking the Fetch button:
For other data (binary data such as pictures) you can use the Fetch to File button to save the request to a file.
The Authentication tab is used to provide Basic Authentication should the web service require it.
The Request Content tab can be used to provide Content data that the request might need. For example, the Eddie’s Electronics web service also lets you request the details for a specific customer by providing simple JSON containing the customer ID. To try this using RESTy app:
- Click on the Request Content Tab.
- To indicate the customer you wish to retrieve, enter the following JSON into the field on that tab:
- Select POST from the Send Method popup menu.
- In the URL field, enter:
- Press the Fetch button.
If you have entered everything correctly, will see the data for Caleb Horn in JSON format:
And to see the JSON formatted nicely, click the Format JSON button:
This will let you you explore calling various REST API services. You can explore the source code to see how it uses URLConnection to do so.
To be sure, RESTy is very basic, but you have the source code so you and add features to it and modify it for your own testing needs.