# Try to use REST API to start and stop recording from a live stream

**URL:** <https://community.wowza.com/t/try-to-use-rest-api-to-start-and-stop-recording-from-a-live-stream/45576>\
**Category:** Wowza Developer Dojo\
**Created:** [July 3, 2015, 6:47am UTC](https://community.wowza.com/t/try-to-use-rest-api-to-start-and-stop-recording-from-a-live-stream/45576 "2015-07-03T06:47:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pier-Olivier\_Thibaul](https://avatars.discourse-cdn.com/v4/letter/p/4491bb/32.png) [@Pier-Olivier\_Thibaul](https://community.wowza.com/u/Pier-Olivier_Thibaul)\
**Post date:** [July 3, 2015, 6:47am UTC](https://community.wowza.com/t/try-to-use-rest-api-to-start-and-stop-recording-from-a-live-stream/45576/1 "2015-07-03T06:47:34Z")

</div>

Hi,

I’m trying to build a web application that could start and stop recording from a Wowza stream through the REST API that wowza provides. First, I can retrieve the list of instances that are currently recording

```auto
% curl http://192.168.1.126:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances/_definst_/streamrecorders
<?xml version="1.0" encoding="UTF-8" ?>
<StreamRecorders restURI="http://192.168.1.126:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances/_definst_/streamrecorders">
  <InstanceName></InstanceName>
  <streamRecorders restURI="/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances//streamrecorders/m.stream">
    <RecorderName>m.stream</RecorderName>
    <InstanceName></InstanceName>
    <RecorderState>Recording in Progress</RecorderState>
    <DefaultRecorder>false</DefaultRecorder>
    <SegmentationType>None</SegmentationType>
    <OutputPath>C:\Program Files (x86)\Wowza Media Systems\Wowza Streaming Engine 4.1.2\content</OutputPath>
    <BaseFile>2m.stream.mp4</BaseFile>
    <FileFormat>MP4</FileFormat>
    <FileVersionDelegate>com.wowza.wms.livestreamrecord.manager.StreamRecorderFileVersionDelegate</FileVersionDelegate>
    <FileTemplate>${SourceStreamName}_${RecordingStartTime}_${SegmentNumber}</FileTemplate>
    <SegmentDuration>832632</SegmentDuration>
    <SegmentSize>10485760</SegmentSize>
    <SegmentSchedule>0 1 * * * *</SegmentSchedule>
    <RecordData>false</RecordData>
    <StartOnKeyFrame>true</StartOnKeyFrame>
    <Option>Overwrite existing file</Option>
    <MoveFirstVideoFrameToZero>true</MoveFirstVideoFrameToZero>
    <CurrentSize>291399785</CurrentSize>
    <CurrentDuration>832632</CurrentDuration>
    <CurrentFile>C:\Program Files (x86)\Wowza Media Systems\Wowza Streaming Engine 4.1.2\content\2m.stream.mp4</CurrentFile>
    <RecordingStartTime>2015-07-03-10.00.50.491-EDT</RecordingStartTime>
  </streamRecorders>
</StreamRecorders>% 

```

Now, I am trying to start and stop new recording with the API. Starting a recording does not work:

```auto
curl -X POST http://admin:admin@192.168.1.126:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances/_definst_/streamrecorders
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  <error>
    <wowzaServer>4.2.0</wowzaServer>
    <code>500</code>
    <message>The server encountered an unexpected condition which prevented it from fulfilling the request</message>
</error>

```

Neither does Stop recording:

```auto
curl -X PUT http://admin:admin@192.168.1.126:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances/_definst_/streamrecorders/m.stream/actions/stopRecording
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  <error>
    <wowzaServer>4.2.0</wowzaServer>
    <code>500</code>
    <message>The server encountered an unexpected condition which prevented it from fulfilling the request</message>
</error>

```

This seems to happen because of a Null exception:

```auto
class com.wowza.wms.rest.vhosts.applications.instances.streamrecorders.StreamRecorderConfig.post : java.lang.NullPointerException
  |at com.wowza.wms.rest.ConfigBase.getObject(Unknown Source)
  |at com.wowza.wms.rest.ConfigBase.post(Unknown Source)
  |at com.wowza.wms.rest.ConfigBase.post(Unknown Source)
  |at org.restlet.resource.ServerResource.doHandle(ServerResource.java:454)
  |at org.restlet.resource.ServerResource.doNegotiatedHandle(ServerResource.java:683)|

```

Even though the path says otherwise, the version of Wowza I’m trying this on is Engine Version 4.2.0 (build 15089)

---

<div class="post-metadata">

**Author:** ![Jason\_Hilton](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/jason_hilton/32/437_2.png) [@Jason\_Hilton](https://community.wowza.com/u/Jason_Hilton)\
**Post date:** [July 6, 2015, 2:26pm UTC](https://community.wowza.com/t/try-to-use-rest-api-to-start-and-stop-recording-from-a-live-stream/45576/2 "2015-07-06T14:26:58Z")

</div>

Hi,

This will be handled in the ticket that you created (133384).

Regards,

Jason

---

<div class="post-metadata">

**Author:** ![George\_Baker](https://avatars.discourse-cdn.com/v4/letter/g/96bed5/32.png) [@George\_Baker](https://community.wowza.com/u/George_Baker)\
**Post date:** [July 10, 2015, 2:59pm UTC](https://community.wowza.com/t/try-to-use-rest-api-to-start-and-stop-recording-from-a-live-stream/45576/3 "2015-07-10T14:59:38Z")

</div>

I just had a similar issue , [REST API Recording doesnt work](http://community.wowza.com/t/-/39627) , checking if you found any solutions so far .

---

<div class="post-metadata">

**Author:** ![Paul\_Shields](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/paul_shields/32/390_2.png) [@Paul\_Shields](https://community.wowza.com/u/Paul_Shields)\
**Post date:** [July 13, 2015, 3:05pm UTC](https://community.wowza.com/t/try-to-use-rest-api-to-start-and-stop-recording-from-a-live-stream/45576/4 "2015-07-13T15:05:42Z")

</div>

Hi,

You could try something like the following to instigate a recording of an existing live stream,

```auto
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/instances/_definst_/streamrecorders/myStream -d '
{
 "restURI":"http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances/_definst_/streamrecorders/myStream",
 "recorderName":"myStream",
"instanceName":"_definst_",
"recorderState":"Waiting for stream",
"defaultRecorder":true,
"segmentationType":"None",
"outputPath":"/usr/local/WowzaStreamingEngine/content",
"baseFile":"myrecord2.mp4",
"fileFormat":"MP4",
"fileVersionDelegateName":"com.wowza.wms.livestreamrecord.manager.StreamRecorderFileVersionDelegate",
"fileTemplate":"${BaseFileName}_${RecordingStartTime}_${SegmentNumber}",
"segmentDuration":900000,
"segmentSize":10485760,
"segmentSchedule":"0 * * * * *",
"recordData":true,
"startOnKeyFrame":true,
"option":"Version existing file",
"moveFirstVideoFrameToZero":true,
"currentSize":0,
"currentDuration":0,
"recordingStartTime":""
}'

```

(replacing app, stream name, path etc accordingly).

More details can be [found here](https://www.wowza.com/docs/how-to-use-curl-to-query-wowza-rest-api#record)

Paul

---

<div class="post-metadata">

**Author:** ![Rustem\_Burak\_Tokdemi](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@Rustem\_Burak\_Tokdemi](https://community.wowza.com/u/Rustem_Burak_Tokdemi)\
**Post date:** [August 24, 2019, 5:01am UTC](https://community.wowza.com/t/try-to-use-rest-api-to-start-and-stop-recording-from-a-live-stream/45576/5 "2019-08-24T05:01:34Z")

</div>

if its not a secret can we also please learn the solution @Jason Hilton

im having the same issue
