# Creating SMIL files using REST API

**URL:** <https://community.wowza.com/t/creating-smil-files-using-rest-api/52600>\
**Category:** Wowza Developer Dojo\
**Created:** [January 4, 2019, 4:29pm UTC](https://community.wowza.com/t/creating-smil-files-using-rest-api/52600 "2019-01-04T16:29:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emily\_Cambridge](https://avatars.discourse-cdn.com/v4/letter/e/a88e4f/32.png) [@Emily\_Cambridge](https://community.wowza.com/u/Emily_Cambridge)\
**Post date:** [January 4, 2019, 4:29pm UTC](https://community.wowza.com/t/creating-smil-files-using-rest-api/52600/1 "2019-01-04T16:29:24Z")

</div>

Hi,

I’m trying to create a smil file using the Wowza REST API. I can successfully create it using the Wowza Streaming Engine REST API Documentation Server but not with Postman or PHP cURL requests.

I can create a stream file using both Postman and PHP without a problem, but when I try to create a smil file I get the error “The server encountered an unexpected condition which prevented it from fulfilling the request”.

![](https://www.wowza.com/community/storage/attachments/1534-postman.png)

Any ideas on how to solve this would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![Rose\_Power-Wowza\_Com](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/rose_power-wowza_com/32/431_2.png) [@Rose\_Power-Wowza\_Com](https://community.wowza.com/u/Rose_Power-Wowza_Com)\
**Post date:** [January 4, 2019, 7:24pm UTC](https://community.wowza.com/t/creating-smil-files-using-rest-api/52600/2 "2019-01-04T19:24:09Z")

</div>

Hi [@Emily Cambridge](http://community.wowza.com/community/questions/50257/creating-smil-files-using-rest-api.html#), sorry for your issues with this. Did you already follow this Wowza doc to create the SMIL file with PHP? I know you said you can create a stream file, but trying to rule out some things first.

[https://www.wowza.com/docs/smil-files-php-query-examples-for-the-wowza-streaming-engine-rest-api](https://www.wowza.com/docs/smil-files-php-query-examples-for-the-wowza-streaming-engine-rest-api)

I’ll share your screenshots with tech support and see if they can quickly identify the issue. They may need you to submit a support ticket to take a closer look at your files. I will let you know. Thanks.

---

<div class="post-metadata">

**Author:** ![Emily\_Cambridge](https://avatars.discourse-cdn.com/v4/letter/e/a88e4f/32.png) [@Emily\_Cambridge](https://community.wowza.com/u/Emily_Cambridge)\
**Post date:** [March 25, 2019, 5:59pm UTC](https://community.wowza.com/t/creating-smil-files-using-rest-api/52600/3 "2019-03-25T17:59:18Z")

</div>

Hi guys, I got it working a few days later but I neglected to put an update here… I was basically just excluding some info, which I found later from the following link:

[https://www.wowza.com/docs/smil-files-query-examples](https://www.wowza.com/docs/smil-files-query-examples)

I’ve included an excerpt of my PHP code below:

```auto
##### Adding the smil file
 $url = "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/smilfiles/apiTest";
 
 $target = array(
 "restURI" => "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/smilfiles/apiTest",
 "title" => "apiTest",
 "smilStreams" => [ array(
 "src" => "apiTest.stream",
 "type" => "video",
 "systemLanguage" => "en",
 "videoBitrate" => "1000000",
 "audioBitrate" => "160000",
 "restURI" => "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/smilfiles/apiTest"
 )]);
 
 #var_dump($target["enabled"]);
 $json = json_encode($target);
 $ch = curl_init();
 
 curl_setopt_array($ch, array(
 CURLOPT_URL => $url,
 CURLOPT_POST => true,
 CURLOPT_POSTFIELDS => $json,
 CURLOPT_HEADER => false,
 CURLOPT_RETURNTRANSFER => true,
 CURLOPT_CUSTOMREQUEST => "POST",
 CURLOPT_USERPWD => "admin:admin",
 CURLOPT_HTTPAUTH => CURLAUTH_DIGEST,
 ));
 curl_setopt($ch, CURLOPT_HTTPHEADER, array(
 'Accept:application/json; charset=utf-8',
 'Content-type:application/json; charset=utf-8',
 'Content-Length: '.strlen($json)));
 
 $contents = curl_exec($ch);
 curl_close($ch);
 $ch = curl_init();
 $obj = json_decode($contents);
 print_r($obj);

```

---

<div class="post-metadata">

**Author:** ![Rose\_Power-Wowza\_Com](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/rose_power-wowza_com/32/431_2.png) [@Rose\_Power-Wowza\_Com](https://community.wowza.com/u/Rose_Power-Wowza_Com)\
**Post date:** [March 25, 2019, 6:00pm UTC](https://community.wowza.com/t/creating-smil-files-using-rest-api/52600/4 "2019-03-25T18:00:42Z")

</div>

That’s really nice of you to return and update the forums for others. Glad you got it working @Emily Cambridge!
