Syntax Api

Need help? Post your questions here.

Moderator: moderators

Syntax Api

Postby toolman » Tue Sep 13, 2016 8:23 pm

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.
toolman
 
Posts: 538
Joined: Fri Dec 11, 2009 4:18 pm
Location: Netherlands

Re: Syntax Api

Postby acroyear » Tue Sep 13, 2016 8:27 pm

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&
--
Joe Shelby
http://subfiresuite.com/
http://subfireplayer.net/
User avatar
acroyear
 
Posts: 779
Joined: Wed Mar 27, 2013 8:05 pm
Location: Northern, VA

Re: Syntax Api

Postby toolman » Tue Sep 13, 2016 10:11 pm

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
toolman
 
Posts: 538
Joined: Fri Dec 11, 2009 4:18 pm
Location: Netherlands

Re: Syntax Api

Postby acroyear » Tue Sep 13, 2016 10:53 pm

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.
--
Joe Shelby
http://subfiresuite.com/
http://subfireplayer.net/
User avatar
acroyear
 
Posts: 779
Joined: Wed Mar 27, 2013 8:05 pm
Location: Northern, VA

Re: Syntax Api

Postby toolman » Tue Sep 13, 2016 11:56 pm

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.
toolman
 
Posts: 538
Joined: Fri Dec 11, 2009 4:18 pm
Location: Netherlands

Re: Syntax Api

Postby acroyear » Wed Sep 14, 2016 3:11 am

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?).
--
Joe Shelby
http://subfiresuite.com/
http://subfireplayer.net/
User avatar
acroyear
 
Posts: 779
Joined: Wed Mar 27, 2013 8:05 pm
Location: Northern, VA

Re: Syntax Api

Postby toolman » Wed Sep 14, 2016 10:40 am

I found that I can use this api without authentication when I'm already logged in to Subsonic as admin.
toolman
 
Posts: 538
Joined: Fri Dec 11, 2009 4:18 pm
Location: Netherlands

Re: Syntax Api

Postby acroyear » Wed Sep 14, 2016 5:27 pm

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.
--
Joe Shelby
http://subfiresuite.com/
http://subfireplayer.net/
User avatar
acroyear
 
Posts: 779
Joined: Wed Mar 27, 2013 8:05 pm
Location: Northern, VA


Return to Help

Who is online

Users browsing this forum: No registered users and 29 guests