REST api usage

Gabriel T

Member
Hello
im trying to make rest calls with jquery, but i have a 415 (unsupported media type) error. here is my script:

function getActiveStreams() {
$.ajax({
type: "POST",
dataType:"json",
contentType:"application/json",
url: "https://myserverwcs5:8888/rest-api/stream/find",
processData: false,
contentType: false,
data: '{"name":"<?=$_SESSION['roomID']; ?>"}'
}).done(function( response ) {
console.log(response);
});
}

additionnaly there is allow origin error (my call is made from a different server where wcs is installed)

thank you
 

Max

Administrator
Staff member
You set
Code:
contentType: false
That's why it does not work.

Regarding cross-domain issue, we will check if we can avoid this.
 

Gabriel T

Member
damned, should have seen that one :D
its getting better but yes cross domain issue still exists, will try with curl requests and php
 

Gabriel T

Member
been able to have it working by making a curl url from php file hosted on same server as wcs, and loading this php from remote server.
so far i retrieve all streams currently connected. i would need to get only published streams in specific room to have lighter requests. have been able to retrieve what i want using rest-api/stream/find/name insteand of rest-api/stream/find_all.

is the "name" filter of the fin method is related to room name or stream name ? said differently, is it possible to list only streams connected to specific room ?

thank you
 

Max

Administrator
Staff member

Gabriel T

Member
yes this is what i finally did, even though i think its a bit heavy process (i mean it will make big queries when there will be hundreds or thousands of connections...) having room name as filter would make these requests much lighter. but its working, thank you
 

Max

Administrator
Staff member
We can add a simple regexp filter for stream name.
For example,
name:stream*
To select all streams stream1, stream2, etc.
It should help to reduce selection weight.
 

Max

Administrator
Staff member
additionnaly there is allow origin error (my call is made from a different server where wcs is installed)
We have added CORS headers for API urls like:
/rest-api/stream
etc
So it should work cross-domain now.
You can update to the latest build 2323
Code:
service webcallserver update
 
Top