Symptoms

I need to pass an entire model constructed in APS UI to a custom operation on endpoint, how can I do that?

Resolution

You can pass the model as data for aps/xhr and retrieve it from arguments passed into custom operation, here is an example on how a service user can create a VM from his control panel (MyCP)

UI view:

//call the createVM() method and send along the instance info
var url1 = "/aps/2/resources/" + aps.context.vars.enduser.aps.id+ "/createVM";
    xhr(url1, { method: "POST", data: JSON.stringify(window.model)})
        .then(function(){
            aps.apsc.gotoView("mycp-main");
        });

endpoint code:

/**
* @verb(POST)
* @path("/createVM")
* @param(string, body)
* @access(referrer, true)
*/

###########################
## createVM
###########################
public function createVM($vm){
    $this->logger("createVM()::Start with:::> ". $vm);
    $apsc = \APS\Request::getController();
    $x = $apsc->getIo()->sendRequest(\APS\Proto::POST, "/aps/2/resources", $vm);
    return $x;
}

Internal content