Results 1 to 5 of 5

Thread: Wowza rest api to Create Application given Unauthorized

  1. #1
    Join Date
    Aug 2015
    Posts
    4

    Default Wowza rest api to Create Application given Unauthorized

    Hi i am trying to create application using rest api

    Application objroot = new Application();
    //Create Application Object//
    objroot.restURI = "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/" + name;
    objroot.name = name;
    objroot.appType = appType;
    objroot.clientStreamReadAccess = "*";
    objroot.clientStreamWriteAccess = "*";
    objroot.description = description;
    StreamConfig objstreamingconfig = new StreamConfig();
    objstreamingconfig.restURI = "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/"+name+"/streamconfiguration";
    objstreamingconfig.streamType = appType;
    //////////////////////////

    objroot.streamConfig = objstreamingconfig;
    //call Http client to post rest api....
    HttpClient client = new HttpClient();
    client.BaseAddress = new Uri("http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/"+name+" -d");

    //to set credentials on
    var byteArray = Encoding.ASCII.GetBytes(UserName + ":" + Password);
    client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
    ////////////////

    here i am getting response : Unauthorized

    Please help me, what i am doing wrong ?

  2. #2
    Join Date
    May 2013
    Posts
    680

    Default

    Hello

    It's uncertain as to what else is going on in the code there but I'd urge you to start with a curl request and then move that into your code base from there:

    Simple example creating "testlive" application:
    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/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"
       }
    }'
    When you run your application I'd suggest printing out the generated json along with the headers used to ensure that it matches similarly to the above curl request. Should you have further problems please provide your post data along with your conf/ and logs/ (as a zip file) and send it to support@wowza.com.

    Thanks,
    Matt

  3. #3
    Join Date
    Aug 2015
    Posts
    4

    Default

    Thanks for reply.

    above code is working on my local side. the same code i am using on server ( dedicated server with remote desktop) its return response : Unauthorized

    while when i uses rest api to get application list, this works on both computer ( my local and server) and return list of applications.

    http://localhost:8087/v2/servers/_de..._/applications

    i thought this is problem of users, but i am using admin that have full access, but still i am getting issue .


    below is Error Details

    StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:\u000d\u000a{\u000d\u000a Connection: keep-alive\u000d\u000a Transfer-Encoding: chunked\u000d\u000a Accept-Ranges: bytes\u000d\u000a Date: Wed, 16 Sep 2015 06:47:47 GMT\u000d\u000a Server: Restlet-Framework\/2.2.2\u000d\u000a WWW-Authenticate: Digest realm=\"Wowza\", domain=\"\/\", nonce=\"MTQ0MjM4NjA2Nzg0NTpkYzg3OGQwZDEwNjU3YTFkMDljODdjZjgzZTgxYTdlZA==\", algorithm=MD5, qop=\"auth\"\u000d\u000a Content-Type: text\/xml; charset=UTF-8\u000d\u000a}


    while on the success on local i am getting response

    ReasonPhrase: 'Created', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:\u000d\u000a{\u000d\u000a Connection: keep-alive\u000d\u000a Transfer-Encoding: chunked\u000d\u000a Accept-Ranges: bytes\u000d\u000a Date: Wed, 16 Sep 2015 07:02:43 GMT\u000d\u000a Server: Restlet-Framework\/2.2.2\u000d\u000a Content-Type: application\/json\u000d\u000a}"

    Thanks
    Last edited by rohit.p; 09-16-2015 at 12:03 AM.

  4. #4
    Join Date
    Aug 2015
    Posts
    4

    Default

    Hi,

    Issue has been fixed. I found problem is on [wowza-install-dir]/conf/Server.xml file on Server. I changed the AuthenticationMethod to 'basic' and restart Wowza Streaming Engine service.

    and now its works.

  5. #5

    Default

    Thanks for the update and glad you got this sorted.

    Salvadore

Similar Threads

  1. Issue on Create new application from REST API
    By rohit.p in forum Wowza Streaming Engine REST API
    Replies: 1
    Last Post: 08-24-2015, 06:32 AM
  2. API rest start/stop/restart application live tream
    By jormarcha in forum Wowza Streaming Engine REST API
    Replies: 1
    Last Post: 03-13-2015, 01:20 PM
  3. Add application using the REST API
    By szidonia in forum General Forum
    Replies: 1
    Last Post: 02-23-2015, 09:31 AM
  4. Redirect unauthorized clients from LIVE to VOD
    By lokki7 in forum Server-side Modules and Code Samples Discussion
    Replies: 9
    Last Post: 11-09-2011, 07:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •