[ CCode ( cname = "rest_proxy_call_async" ) ]
public bool run_async (ProxyCallAsyncCallback callback, Object? weak_object = null) throws Error

Asynchronously invoke this.

When the call has finished, callback will be called. If weak_object is disposed during the call then this call will be cancelled. If the call is cancelled then the callback will be invoked with an error state.

You may unref the call after calling this function since there is an internal reference, or you may unref in the callback.

Example: Read raw data, async:

public static int main (string[] args) {
try {
MainLoop loop = new MainLoop ();

Rest.Proxy proxy = new Rest.Proxy ("", false);
Rest.ProxyCall call = proxy.new_call ();
call.add_params (
"method", "flickr.test.echo",
"api_key", "314691be2e63a4d58994b2be01faacfb",
"format", "json"

call.run_async ((call, error, obj) => {
string payload = call.get_payload ();
int64 len = call.get_payload_length ();

// We interpret the result as data:
unowned uint8[] arr = (uint8[]) payload;
arr.length = (int) len;
stdout.write (arr, sizeof (uint8));

loop.quit ();
}, null); ();
} catch (Error e) {
stderr.puts (e.message);
stderr.putc ('\n');
return 0;

valac --pkg rest-0.7 test-raw-async.vala



The ProxyCall


a ProxyCallAsyncCallback to invoke on completion of the call


The Object to weakly reference and tie the lifecycle too


data to pass to callback