Forum Discussion
My Problem:
I create successfully a transaction and added tasks to it (add a vlan and route-domain). When i check the commands list I get:
object(stdClass)[3]
public 'kind' => string 'tm:transaction:commandscollectionstate' (length=38)
public 'selfLink' => string 'https://localhost/mgmt/tm/transaction/1484740224001215/commands?ver=12.1.0' (length=74)
public 'items' =>
array (size=2)
0 =>
object(stdClass)[4]
public 'method' => string 'POST' (length=4)
public 'uri' => string 'https://localhost/mgmt/tm/net/vlan' (length=34)
public 'body' =>
object(stdClass)[5]
public 'name' => string 'testvlan' (length=8)
public 'tag' => string '627' (length=3)
public 'interfaces' =>
array (size=1)
0 =>
object(stdClass)[6]
...
public 'evalOrder' => int 1
public 'commandId' => int 1
public 'kind' => string 'tm:transaction:commandsstate' (length=28)
public 'selfLink' => string 'https://localhost/mgmt/tm/transaction/1484740224001215/commands/1?ver=12.1.0' (length=76)
1 =>
object(stdClass)[7]
public 'method' => string 'POST' (length=4)
public 'uri' => string 'https://localhost/mgmt/tm/net/route-domain' (length=42)
public 'body' =>
object(stdClass)[8]
public 'name' => string 'testRD' (length=6)
public 'id' => string '4533' (length=4)
public 'vlans' =>
array (size=1)
0 => string '/Common/testvlan' (length=16)
public 'evalOrder' => int 2
public 'commandId' => int 2
public 'kind' => string 'tm:transaction:commandsstate' (length=28)
public 'selfLink' => string 'https://localhost/mgmt/tm/transaction/1484740224001215/commands/2?ver=12.1.0' (length=76)
But when I try to commit the transaction, i only get a HTTP 415 and the transaction state stays at "UPDATING".
object(stdClass)[3]
public 'transId' => string '1484740224001215' (length=16)
public 'state' => string 'UPDATING' (length=8)
public 'timeoutSeconds' => int 120
public 'asyncExecution' => boolean false
public 'validateOnly' => boolean false
public 'executionTimeout' => int 300
public 'executionTime' => int 0
public 'failureReason' => string '' (length=0)
public 'kind' => string 'tm:transactionstate' (length=19)
public 'selfLink' => string 'https://localhost/mgmt/tm/transaction/1484740224001215?ver=12.1.0' (length=65)
My php/curl transaction function looks like this:
public function executeTransaction($transId)
{
$ch = curl_init($this->BASE_URL . "/transaction/" . $transId);
$encoded_data = '{ "state":"VALIDATING" }';
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PATCH");
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERPWD, "$this->username:$this->password");
$result = curl_exec($ch);
$this->code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
return json_decode($result, false, 512, JSON_BIGINT_AS_STRING);
}
Does anyone has a hint for me?
- Ichnafi_177360Jan 19, 2017Nimbostratus
To Answer my own Question:
You have to specify a header with Content-Type (and optional Content-Length) BUT you have to omit the 'X-F5-REST-Coordination-Id:' in it. So I added the follwing curl-option to my function. It works now.
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($encoded_data)) );
- IchnafiJan 19, 2017Cirrostratus
To Answer my own Question:
You have to specify a header with Content-Type (and optional Content-Length) BUT you have to omit the 'X-F5-REST-Coordination-Id:' in it. So I added the follwing curl-option to my function. It works now.
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($encoded_data)) );