<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{tenant}/tyk/apis/{apiID}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'api_id' => 'b84fe1a04e5648927971c0557971565c',
'auth' => [
'auth_header_name' => 'authorization'
],
'definition' => [
'key' => 'version',
'location' => 'header'
],
'name' => 'Update the API name sample',
'org_id' => '664a14650619d40001f1f00f',
'proxy' => [
'listen_path' => '/update-listen-path',
'strip_listen_path' => true,
'target_url' => 'https://tyk.io/api'
],
'use_oauth2' => true,
'version_data' => [
'not_versioned' => true,
'versions' => [
'Default' => [
'name' => 'Default'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Tyk-Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}