Symptoms

In my application I have a reference to Operations Automation subscription, in custom UI it is possible to fetch subscription resources related to my application with a GET request:

GET https://<aps_controller_uri>:6308/aps/2/resources/<subscription_aps_id>/resources

When I try to fetch the same URL from PHP runtime like this:

$resources = \APS\Request::getController()->GetResources(null, 'aps/2/resources/'.$this->subscription->aps->id.'/resources');

, I get an empty array.

Cause

GetResources method can only work with children of 'APS::ResourceBase' class, and 'SubscriptionResource' is not descended from it.

Resolution

Starting from PHP runtime aps-php-runtime-2.0-287 you can fetch subscription resources like this:

  • If you do not have a link to subscription in your application resource:

    $subscrResource = $apsc->getResource($subscr_resource_id);
    $resources = $subscrResource->resources();
    
  • If your application resource has a link to subscription:

    $resources = $this->subscription->resources();
    

Properties of the 'SubscriptionResource' structure are described in documentation

Internal content

Link on internal Article