I'm about to go down the same path here. I have a rough idea of what I need to do. I'm going to try to use the %Net.HttpRequest object and do at least the following steps:

1. Create a new %Net.HttpRequest object

set myrequest = ##class(%Net.HttpRequest).%New()

2. Set the server

set myrequest.server = "www.whatever.com"

3. Set the locatoin

set myrequest.location = "/path/to/rest"

4. Create a global binary stream.

5. Write json data to the stream.

6. Use the stream as the EntityBody for the HttpRequest.

7. Call the get, put, or post method of the HttpRequest object to consume.

8. Use the HttpRequest's HttpResponse object to check the response

Somewhere in your button tag, you have onselect= something. Buttons don't have an onselect, but even if they did, I'm guessing that's not the event you actually want. onselect happens when a user highlights text within a control, like in a text input.

If you're trying to set what happens when the user clicks the button, that's onclick.

If you're trying to set what happens when the user selects the button but doesn't click it (say by pressing tab until the button is highlighted) that's onfocus.

ObjectScript variables are untyped, so preserving the type isn't necessary.

You'll build the list by adding your MyPackage.MyClass objects to it, then you'll return the %ListOfObjects, then you'll use that list's methods to manipulate those objects. For instance, set mything = mylist.GetAt(1) will give you an object that is identical to the MyPackage.MyClass object you put in the list with all of its properties an methods.