Wowza Community

Post/create multiple objects

Is it possible to use the REST API to create multiple Wowza objects using a single POST request? I’ve looked around for examples or documentation and I have tried some test calls, but I have been unsuccessful. If possible, I’d rather send 1 request with an array of objects to the server rather than looping through my data and sending another POST request.

If it matters, I am interested in creating multiple stream files or multiple transcoder templates.

Here is an example I tried:

curl -H "Content-Type: application/json" -X POST "http://wowza:port/v2/servers/{servername}/vhosts/{vhost}/applications/{applicationname}/streamfiles" -d
'[{
  "name": "stream_file1",
  "uri": "uri://1"
},
{
  "name": "stream_file1",
  "uri": "uri://1"
},
{
  "name": "stream_file1",
  "uri": "uri://1"
}]'

Wowza sends a malformed syntax response. Is there something I’m missing in my data? is something like this even possible?

Hi,

I don’t believe that is possible. The endpoint has the name of the stream file you’re adding at the end of the URI, for example adding the stream file axis.stream

curl -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/live/streamfiles/axis -d'
{
   "restURI": "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/streamfiles",
   "streamFiles": [
      {
         "id": "connectAppName= live&appInstance=_definst_&mediaCasterType=rtp",
         "href": "http://localhohst:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/streamfiles/connectAppName=live&appInstance=_definst_&mediaCasterType=rtp"
      }
   ]
}'

Regards,

Paul

I don’t believe that is possible. The endpoint has the name of the stream file you’re adding at the end of the URI, for example adding the stream file axis.stream

I don’t believe this is necessarily true. Perhaps my first POST data was malformed now that I see it again, but I can use the /streamfiles endpoint to add a single stream file. Something like this (test application is ‘Recorder’):

curl -X POST "http://server_address/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/Recorder/streamfiles" -d 
    {
      "name": "stream_test",
      "uri": "/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/Recorder/streamfiles/stream_test"
    }

Something like this will simple create single stream file named “stream_test.stream” in my Recorder application.

Is it not possible to create a JSON array of “name” and “uri” to create a number of stream files using one request? how would I format this JSON array of multiple streamfiles?

Here is my updated test.

curl -X POST "http://server_address/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/Recorder/streamfiles" -d
{
  "streamFiles": [
     {
       "id": "stream_b",
       "href": "/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/Recorder/streamfiles/stream_b"
     },
     {
       "id": "stream_a",
       "href": "/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/Recorder/streamfiles/stream_a"
     }
  ]
}

I actually get a response of success = true, but I do not see these stream files (stream_a.stream, stream_b.stream) added to my application. I am not sure why the server is returning success, in this case.

Hi,

Unfortunately, that REST API endpoint does not currently support an array list of values. I will raise this with our Engineering team to add this as an enhancement in a future release, and to add the correct error return code for now.

Michelle