# RESTful API using CURL does not work as expected

**URL:** https://community.wowza.com/t/restful-api-using-curl-does-not-work-as-expected/45690
**Category:** Wowza Streaming Engine
**Created:** [July 22, 2015, 6:17pm UTC](https://community.wowza.com/t/restful-api-using-curl-does-not-work-as-expected/45690 "2015-07-22T18:17:52Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Taha\_Ansari](https://avatars.discourse-cdn.com/v4/letter/t/e19b73/32.png) [@Taha\_Ansari](https://community.wowza.com/u/Taha_Ansari)
#### Post date: [July 22, 2015, 6:17pm UTC](https://community.wowza.com/t/restful-api-using-curl-does-not-work-as-expected/45690/1 "2015-07-22T18:17:52Z")

</div>

Good M@rning!

I have a scenario where I have setup a basic Wowza server instance on my PC (localhost). Now, I would like to use restful API with Wowza using curl. I got some basic direction here: [https://www.wowza.com/docs/how-to-use-curl-to-query-wowza-rest-api](https://www.wowza.com/docs/how-to-use-curl-to-query-wowza-rest-api), but, with whatever queries I tried (either GET or POST method), I always get the same error: “The request requires user authentication”.

For example, I tried different combinations:

```auto
curl -X GET --header 'Accept:application/json; charset=utf-8' http://taha:a1@localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications
curl -X GET --header 'Accept:application/json' http://taha:a1@localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications
curl -X GET --header 'Accept:application/json; charset=utf-8' http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications
curl -X POST -H "Accept:application/json; charset=utf-8" -H "Content-type:application/json; charset=utf-8" http://taha:a1@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://taha:a1@localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamconfiguration","streamType":"live"}}'
curl -X GET --header 'Accept:application/json; charset=utf-8' http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles

```

All return the same error:

```auto
C:\Users\Admin>curl -X GET --header 'Accept:application/json; charset=utf-8' http://taha:a1@localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications
curl: (6) Couldn't resolve host 'charset=utf-8''
<?xml version="1.0" encoding="UTF-8" standalone="no"?><error><wowzaServer>4.2.0</wowzaServer><code>401</code><message>The request requires user authentication</message></error>
C:\Users\Admin>

```

I noticed this error message is not documented in the page referenced, what am I missing?

**Note:** taha is username, and a1 is password. I tried different combinations, with and without the username/password string so it may not display the same error over and over.

Wowza server version is 4.2.0.

Thanks…

---

<div class="post-metadata">

### Author: ![Zoran](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/zoran/32/385_2.png) [@Zoran](https://community.wowza.com/u/Zoran)
#### Post date: [July 22, 2015, 3:43pm UTC](https://community.wowza.com/t/restful-api-using-curl-does-not-work-as-expected/45690/2 "2015-07-22T15:43:01Z")

</div>

Hello,

Can you try using this instead:

```auto
curl -X GET --header 'Accept:application/json; charset=utf-8' -u taha:a1 http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications

```

Zoran

---

<div class="post-metadata">

### Author: ![Zoran](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/zoran/32/385_2.png) [@Zoran](https://community.wowza.com/u/Zoran)
#### Post date: [July 22, 2015, 7:36pm UTC](https://community.wowza.com/t/restful-api-using-curl-does-not-work-as-expected/45690/3 "2015-07-22T19:36:14Z")

</div>

Hi,

I noticed that you are runnign CURL on a Windows box.

Can you try using this command instead?

```auto
curl -X GET --header "Accept:application/json; charset=utf-8" -u taha:a1 http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications

```

Also, please check your **[wowza-install-dir]/conf/Server.xml** file, if you have the **/Root/Server/RESTInterface/AuthenticationMethod/** parameter set to “basic”.

If you make any changes to the Server.xml file, please make sure to restart your Wowza Streaming Engine service so that the new changes can take effect.

Just to make sure, please check if the _taha_ username and _a1_ password is set in your **[wowza-install-dir]/conf/admin.password** file.

Zoran

---

<div class="post-metadata">

### Author: ![Matt\_Young](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/matt_young/32/389_2.png) [@Matt\_Young](https://community.wowza.com/u/Matt_Young)
#### Post date: [July 28, 2015, 12:15pm UTC](https://community.wowza.com/t/restful-api-using-curl-does-not-work-as-expected/45690/4 "2015-07-28T12:15:49Z")

</div>

Hello tahaOS

I think there is a url issue and some quoting issues at play here. Try the following (note the use of single quote and the removal of the user/pass from the second restURI entry):

```auto
curl -X POST -H "Accept:application/json; charset=utf-8" -H "Content-type:application/json; charset=utf-8" -u "taha:a1" http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive -d '{"restURI":"http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive3","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"}}'

```

---

<div class="post-metadata">

### Author: ![Taha\_Ansari](https://avatars.discourse-cdn.com/v4/letter/t/e19b73/32.png) [@Taha\_Ansari](https://community.wowza.com/u/Taha_Ansari)
#### Post date: [July 22, 2015, 6:46pm UTC](https://community.wowza.com/t/restful-api-using-curl-does-not-work-as-expected/45690/5 "2015-07-22T18:46:48Z")

</div>

Thanks for your prompt reply; its still the same error:

```auto
C:\Users\Admin>curl -X GET --header 'Accept:application/json; charset=utf-8' -u taha:a1 http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications
curl: (6) Couldn't resolve host 'charset=utf-8''
<?xml version="1.0" encoding="UTF-8" standalone="no"?><error><wowzaServer>4.2.0</wowzaServer><code>401</code><message>The request requires user authentication</message></error>
C:\Users\Admin>

```

---

<div class="post-metadata">

### Author: ![Taha\_Ansari](https://avatars.discourse-cdn.com/v4/letter/t/e19b73/32.png) [@Taha\_Ansari](https://community.wowza.com/u/Taha_Ansari)
#### Post date: [July 23, 2015, 11:10am UTC](https://community.wowza.com/t/restful-api-using-curl-does-not-work-as-expected/45690/6 "2015-07-23T11:10:06Z")

</div>

> Hi,
> 
> I noticed that you are runnign CURL on a Windows box.
> 
> Can you try using this command instead?
> 
> ```auto
> curl -X GET --header "Accept:application/json; charset=utf-8" -u taha:a1 http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications
> 
> ```
> 
> Also, please check your **[wowza-install-dir]/conf/Server.xml** file, if you have the **/Root/Server/RESTInterface/AuthenticationMethod/** parameter set to “basic”.
> 
> If you make any changes to the Server.xml file, please make sure to restart your Wowza Streaming Engine service so that the new changes can take effect.
> 
> Just to make sure, please check if the _taha_ username and _a1_ password is set in your **[wowza-install-dir]/conf/admin.password** file.
> 
> Zoran

Many thanks for your prompt reply; all of your suggestions helped in one way or the other.

First, I noticed /Root/Server/RESTInterface/AuthenticationMethod/ parameter was set to ‘digest’, so I changed to ‘basic’ and restarted service.

After restart, when I applied curl string as:

```auto
curl -X GET --header "Accept:application/json; charset=utf-8" -u taha:a1 [url]http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications[/url]

```

(as you suggested), I got response in JSON (as needed):

```auto
{"restURI":"http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications","applications":[{"id":"IP Cam","href":"http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/IP Cam","appType":"Live","dvrEnabled":false,"drmEnabled":false,"transcoderEnabled":false,"streamTargetsEnabled":false},{"id":"live","href":"http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live","appType":"Live","dvrEnabled":false,"drmEnabled":false,"transcoderEnabled":false,"streamTargetsEnabled":false},{"id":"vod","href":"http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/vod","appType":"VOD","dvrEnabled":false,"drmEnabled":false,"transcoderEnabled":false,"streamTargetsEnabled":false}]}

```

And like you mentioned, if I changed it to:

```auto
curl -X GET --header 'Accept:application/json; charset=utf-8' -u taha:a1 http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications

```

(single quotes), I got response in XML format:

```auto
  <Application id="IP Cam" href="http://localhost:8087/v2/servers/_defaultServer
_/vhosts/_defaultVHost_/applications/IP Cam">
    <AppType>Live</AppType>
    <DVREnabled>false</DVREnabled>
    <DRMEnabled>false</DRMEnabled>
    <TranscoderEnabled>false</TranscoderEnabled>
    <StreamTargetsEnabled>false</StreamTargetsEnabled>
  </Application>
  <Application id="live" href="http://localhost:8087/v2/servers/_defaultServer_/
vhosts/_defaultVHost_/applications/live">
    <AppType>Live</AppType>
    <DVREnabled>false</DVREnabled>
    <DRMEnabled>false</DRMEnabled>
    <TranscoderEnabled>false</TranscoderEnabled>
    <StreamTargetsEnabled>false</StreamTargetsEnabled>
  </Application>
  <Application id="vod" href="http://localhost:8087/v2/servers/_defaultServer_/v
hosts/_defaultVHost_/applications/vod">
    <AppType>VOD</AppType>
    <DVREnabled>false</DVREnabled>
    <DRMEnabled>false</DRMEnabled>
    <TranscoderEnabled>false</TranscoderEnabled>
    <StreamTargetsEnabled>false</StreamTargetsEnabled>
  </Application>
</Applications>

```

so your latest string does the trick.

> Just to make sure, please check if the _taha_ username and _a1_ password is set in your **[wowza-install-dir]/conf/admin.password** file.
> 
> Yes, this part was set correctly.
> 
> Thanks for all the help in right direction!

---

<div class="post-metadata">

### Author: ![Taha\_Ansari](https://avatars.discourse-cdn.com/v4/letter/t/e19b73/32.png) [@Taha\_Ansari](https://community.wowza.com/u/Taha_Ansari)
#### Post date: [July 23, 2015, 6:10pm UTC](https://community.wowza.com/t/restful-api-using-curl-does-not-work-as-expected/45690/7 "2015-07-23T18:10:59Z")

</div>

After last done steps, I tried to create an application using REST interface, as follows:

```auto
curl -X POST -H "Accept:application/json; charset=utf-8" -H "Content-type:application/json; charset=utf-8" -u taha:a1 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://taha:a1@localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamconfiguration","streamType":"live"}}"

```

Which returned some error:

```auto
<?xml version="1.0" encoding="UTF-8" standalone="no"?><error><wowzaServer>4.2.0</wowzaServer><code>400</code><message>com.fasterxml.jackson.core.JsonParseException: Unexpected character ('r' (code 114)): was expecting double-quote to start field name at [Source: java.io.ByteArrayInputStream@1390c955; line: 1, column: 3]</message></error><html><head><META HTTP-EQUIV="refresh" CONTENT="0;URL=/cgi-sys/defaultwebpage.cgi"></head><body></body></html>
<html><head><META HTTP-EQUIV="refresh" CONTENT="0;URL=/cgi-sys/defaultwebpage.cgi"></head><body></body></html>
curl: (3) [globbing] unmatched close brace/bracket at pos 168

```

After this, now if I try to open enginemanager using: [http://localhost:8088/enginemanager/login.htm](http://localhost:8088/enginemanager/login.htm)

after login attempt, it gives me a new error:

```auto
Internal Server Error (500) - Internal Server Error 

```

This is something really new - tried stopping/starting wowza services multiple times, but no benefit.

Any clues…?
