如何使用 SoftLayer API 在 Endurance 存储上升级快照 space?
How do you upgrade a Snapshot space on Endurance storage using SoftLayer API?
使用 SoftLayer API,我订购了 Endurance Block Storage,它就在那里。
现在我正在尝试编写 PHP 代码,它将使用 SoftLayer API 修改快照 space,但我不断收到此错误:
There was an error querying the SoftLayer API: Price does not have an id.
而且我不确定问题出在哪里。
下面是我用来执行此操作的一些代码:
$clientServer = SoftLayer_XmlrpcClient::getClient('SoftLayer_Product_Order', null, userID, apiKey);
$clientServer->verifyOrder($order);
我传递的 $order 如下,据我所知,我传递的价格 ID 是正确的。那我错过了什么?或者我需要以不同的方式执行此操作吗?
{
"categoryCode" : "storage_snapshot_space",
"complexType" : "Container_Product_Order_Network_Storage_Enterprise_SnapshotSpace_Upgrade",
"packageId" : 240,
"prices" : [
{
"id" : 144295
}
],
"properties" : [
{
"name" : "orderOrigin",
"value" : "control"
}
],
"virtualGuests" : null
}
如有任何帮助,我们将不胜感激。谢谢。
Json 应该是这样的,其中 volumeId 是将应用升级的块存储 ID。
{
"complexType": "SoftLayer_Container_Product_Order_Network_Storage_Enterprise_SnapshotSpace_Upgrade",
"packageId": 240,
"prices": [{
"id": 144295
}],
"volumeId": 5805095
}
在PHP中是这样的:
<?php
require_once ('C:/scripst/getdetails/SoftLayer/SoapClient.class.php');
$username = 'set me';
$key = 'set me';
$softLayer_product_order = SoftLayer_SoapClient::getClient('SoftLayer_Product_Order', null, $username, $key);
$prices = array
(
46150
);
$orderPrices = array();
foreach ($prices as $priceId){
$price = new stdClass();
$price->id = $priceId;
$orderPrices[] = $price;
}
$packageId = 240;
$volumeId = 5805095;
$orderContainer = new stdClass();
$orderContainer->packageId = $packageId;
$orderContainer->prices = $orderPrices;
$orderContainer->volumeId = $volumeId;
try {
$orderTemplate = new SoapVar
(
$orderContainer,
SOAP_ENC_OBJECT,
'SoftLayer_Container_Product_Order_Network_Storage_Enterprise_SnapshotSpace_Upgrade',
'http://api.service.softlayer.com/soap/v3/'
);
$receipt = $softLayer_product_order->verifyOrder($orderTemplate);
print_r($receipt);
} catch (Exception $e) {
echo 'Unable to place the order: ' . $e->getMessage();
}
不要忘记替换价格和 volumeID
此致
使用 SoftLayer API,我订购了 Endurance Block Storage,它就在那里。 现在我正在尝试编写 PHP 代码,它将使用 SoftLayer API 修改快照 space,但我不断收到此错误:
There was an error querying the SoftLayer API: Price does not have an id.
而且我不确定问题出在哪里。 下面是我用来执行此操作的一些代码:
$clientServer = SoftLayer_XmlrpcClient::getClient('SoftLayer_Product_Order', null, userID, apiKey);
$clientServer->verifyOrder($order);
我传递的 $order 如下,据我所知,我传递的价格 ID 是正确的。那我错过了什么?或者我需要以不同的方式执行此操作吗?
{
"categoryCode" : "storage_snapshot_space",
"complexType" : "Container_Product_Order_Network_Storage_Enterprise_SnapshotSpace_Upgrade",
"packageId" : 240,
"prices" : [
{
"id" : 144295
}
],
"properties" : [
{
"name" : "orderOrigin",
"value" : "control"
}
],
"virtualGuests" : null
}
如有任何帮助,我们将不胜感激。谢谢。
Json 应该是这样的,其中 volumeId 是将应用升级的块存储 ID。
{
"complexType": "SoftLayer_Container_Product_Order_Network_Storage_Enterprise_SnapshotSpace_Upgrade",
"packageId": 240,
"prices": [{
"id": 144295
}],
"volumeId": 5805095
}
在PHP中是这样的:
<?php
require_once ('C:/scripst/getdetails/SoftLayer/SoapClient.class.php');
$username = 'set me';
$key = 'set me';
$softLayer_product_order = SoftLayer_SoapClient::getClient('SoftLayer_Product_Order', null, $username, $key);
$prices = array
(
46150
);
$orderPrices = array();
foreach ($prices as $priceId){
$price = new stdClass();
$price->id = $priceId;
$orderPrices[] = $price;
}
$packageId = 240;
$volumeId = 5805095;
$orderContainer = new stdClass();
$orderContainer->packageId = $packageId;
$orderContainer->prices = $orderPrices;
$orderContainer->volumeId = $volumeId;
try {
$orderTemplate = new SoapVar
(
$orderContainer,
SOAP_ENC_OBJECT,
'SoftLayer_Container_Product_Order_Network_Storage_Enterprise_SnapshotSpace_Upgrade',
'http://api.service.softlayer.com/soap/v3/'
);
$receipt = $softLayer_product_order->verifyOrder($orderTemplate);
print_r($receipt);
} catch (Exception $e) {
echo 'Unable to place the order: ' . $e->getMessage();
}
不要忘记替换价格和 volumeID
此致