Page 1 of 1

Syntax Api

PostPosted: Tue Sep 13, 2016 8:23 pm
by toolman
Hi,
I.ve been trying the Subsonic api's to solve some database problems. I can run the Getgenres-api without any problems and get a full list of genres.
In this list I see some strange genres like:
<genre albumCount="2" songCount="29">Desconocido</genre>
<genre albumCount="1" songCount="28">Tribal</genre>
<genre albumCount="1" songCount="28">Trailer</genre>
Now I want to know what songs have these strange genre-names so I tried to use the getSongsByGenre.view-api but I can't get it to work.
I have used following syntax;
"http://your-server/rest/getSongsByGenre.view&genre=oldies?u=admin&p=adminpassword&v=1.14.0&c=myapp" and some varitions on that but I only get errors like
<error message="Required string parameter 'genre' is not present" code="10"/> or similar errors.
Can somebody tell me what syntax I should use to get this working?
I can't find rhe correct syntax on the documentation-page: http://www.subsonic.org/pages/api.jsp.
Any ideas?
Thanks Toolman.

Re: Syntax Api

PostPosted: Tue Sep 13, 2016 8:27 pm
by acroyear
not sure if just a typo, but you've got the ? and & in the wrong place in the example:

Code: Select all
Genre.view&genre=oldies?u=admin&


it should be
Code: Select all
Genre.view?genre=oldies&u=admin&

Re: Syntax Api

PostPosted: Tue Sep 13, 2016 10:11 pm
by toolman
When I change it as you propose I get:

<?xml version="1.0" encoding="UTF-8"?>
-<subsonic-response xmlns="http://subsonic.org/restapi" version="1.14.0" status="ok">
<songsByGenre/>
</subsonic-response>


So that's not right either.
I have tried a lot of combinations:
/rest/getSongsByGenre.view&genre=oldies?u=admin&p=adminpassword&v=1.14.0&c=myapp
/rest/getSongsByGenre.view?genre=oldies?u=admin&p=adminpassword&v=1.14.0&c=myapp
/rest/getSongsByGenre.view;genre=oldies?u=admin&p=adminpassword&v=1.14.0&c=myapp
/rest/getSongsByGenre.view&genre=oldies&u=admin&p=adminpassword&v=1.14.0&c=myapp
/rest/getSongsByGenre.view?oldies?u=admin&p=adminpassword&v=1.14.0&c=myapp
But The syntax never is correct.

Thanks for your suggestion though.
Toolman

Re: Syntax Api

PostPosted: Tue Sep 13, 2016 10:53 pm
by acroyear
I think you were right when you got the status="ok" reply. Genres are case sensitive. "Oldies" may not be the same as "oldies".

/rest/getSongsByGenre.view?genre=Rock&count=10&offset=0&v=1.14.0&c=SubFire&u=subfire&f=json

That returned results on my server, while

/rest/getSongsByGenre.view?genre=rock&count=10&offset=0&v=1.14.0&c=SubFire&u=subfire&f=json

did not. Count and offset should be optional.

Re: Syntax Api

PostPosted: Tue Sep 13, 2016 11:56 pm
by toolman
Hey Thanks,
That did the trick. '
I saw you ommitted the "user" and "password"-argument. So I thought I just copy your syntax and use that and now I do get results.
Somehow I got the idea that Úser and Password always are required. and I guess that that caused the problem.
Thanks again, this will help me a lot in getting all my tags right.
Kind regards, Toolman.

Re: Syntax Api

PostPosted: Wed Sep 14, 2016 3:11 am
by acroyear
i use the u/s/t combination in subfire for additional safety (not that md5 is very safe, but better than open or the enc: form), but yeah, i cropped those off since they weren't the heart of the 'bug' in your example, and it was easier to crop than to distort. the authentication parameters are always required except for 'ping' (and maybe getLicense?).

Re: Syntax Api

PostPosted: Wed Sep 14, 2016 10:40 am
by toolman
I found that I can use this api without authentication when I'm already logged in to Subsonic as admin.

Re: Syntax Api

PostPosted: Wed Sep 14, 2016 5:27 pm
by acroyear
that's because the primary client login sets a session cookie, which you're sending back to the server to verify. a 3rd party client not going through the home page won't have that feature which is why the documentation specifies that it is required.