Issue 3559: Would like better documentation for using RestApi class from Java code.
Status:  New
Owner: ----
Reported by Jamie.Co...@sas.com, Sep 14, 2015
I need to do a Rest call from my GWT client code in my plugin, but the only example I can find for using the RestApi class is the one in the current documentation, which shows how to change the description for a project.

I need to be able to query open changes... this is what I changed the example to (which blows up with the message "The page you requested does not exist, or you do not have permissions").  With nothing better to go on, I have no idea where to go from here.

        new RestApi("changes")
                   .addParameter("q", queryString)
                   .addParameter("option",ListChangesOption.DETAILED_ACCOUNTS)
                   .addParameter("option",ListChangesOption.DETAILED_LABELS)
                   .get(new AsyncCallback<JavaScriptObject>()
        {
            @Override
            public void onSuccess(JavaScriptObject result)
            {
                // TODO
            }

            @Override
            public void onFailure(Throwable caught)
            {
                // never invoked
            }
        });

Sep 15, 2015
#1 Jamie.Co...@sas.com
Finally stumbled across the correct way to code this:

        // collect the change info
        new RestApi("changes/")
                    .addParameter("q", queryString)
                    .addParameter("o", ListChangesOption.DETAILED_ACCOUNTS.name())
                    .addParameter("o", ListChangesOption.DETAILED_LABELS.name())
                    .get(new AsyncCallback<JavaScriptObject>()
        {
...

Note the explicit trailing slash on the endpoint name, using 'o' instead of 'option', and using the Enum .name() method to pass those options.

Would have saved me about a day's effort if this had been better documented.