Article ID: 124031, created on Dec 25, 2014, last review on Dec 25, 2014

  • Applies to:
  • APS 2.x

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;
}

70bf700e0cdb9d7211df2595ef7276ab 717db81efe94e616312b74fb03a5d474

Email subscription for changes to this article
Save as PDF