Wowza 4.2 REST API


Welcome Wowza REST API. Since Wowza 4.2 no need REST license anymore. However, I not found official REST API documentation, moreover.. I found only 2 articles on wowza forum :/




Seem REST API on Windows have issue.  but on Linux is work fine. here is some PHP code to call Wowza REST API.

create new apps

1. cURL command

curl -v -X POST --header 'Accept: application/json; charset=utf-8' --header 'Content-Type: application/json; charset=utf-8' http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive -d'
{
   "restURI": "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive",
   "name": "testlive",
   "appType": "Live",
   "clientStreamReadAccess": "*",
   "clientStreamWriteAccess": "*",
   "description": "Testing our Rest Service",
   "streamConfig": {
      "restURI": "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamconfiguration",
      "streamType": "live"
   }
}'


2. PHP call REST API
$service_url = 'http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive';
$curl = curl_init($service_url);
$curl_post_data ='
{
   "restURI": "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive",
   "name": "testlive",
   "appType": "Live",
   "clientStreamReadAccess": "*",
   "clientStreamWriteAccess": "*",
   "description": "Testing our Rest Service",
   "streamConfig": {
      "restURI": "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamconfiguration",
      "streamType": "live"
   }
}
';

$headers = array(
'Content-Type: application/json; charset=utf-8',
'Accept: application/json; charset=utf-8' 

);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$curl_response = curl_exec($curl); 
curl_close($curl);

echo $curl_response;


Result

* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8087 (#0)
> POST /v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive HTTP/1.1
Host: localhost:8087
Content-Type: application/json; charset=utf-8
Accept: application/json; charset=utf-8
Content-Length: 461

* upload completely sent off: 461 out of 461 bytes
< HTTP/1.1 201 Created
< Content-Type: application/json
< Date: Wed, 01 Jul 2015 06:55:05 GMT
< Accept-Ranges: bytes
* Server Restlet-Framework/2.2.2 is not blacklisted
< Server: Restlet-Framework/2.2.2
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: OPTIONS,GET,PUT,DELETE,POST
< Connection: keep-alive
< Transfer-Encoding: chunked
<
* Connection #0 to host localhost left intact

{"success":true,"message":"Application (testlive) created successfully.","data":null}

Comments

Popular Posts