Kodi Community Forum
result is null from JSON RPC API - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+---- Forum: JSON-RPC (https://forum.kodi.tv/forumdisplay.php?fid=174)
+---- Thread: result is null from JSON RPC API (/showthread.php?tid=109479)



result is null from JSON RPC API - keepsimple - 2011-09-06

Hi,
I am trying to use JSON RPC API talking to my XBMC v10.0 running on MacOS X. I tried the following calls but got result "null":

telnet localhost 9090

{"jsonrpc": "2.0", "method": "AudioLibrary.GetArtists", "params": {"fields": ["artistid", "label"]}, "id": 1}
{
"id" : 1,
"jsonrpc" : "2.0",
"result" : null
}

{"jsonrpc": "2.0", "method": "AudioLibrary.GetArtists","params":{}, "id":3}
{
"id" : 3,
"jsonrpc" : "2.0",
"result" : null
}

{"jsonrpc": "2.0", "method": "AudioLibrary.GetSongs", "id": 1}
{
"id" : 1,
"jsonrpc" : "2.0",
"result" : null
}

But I can play songs in XBMC and I can see the Announcements via JSON-RPC:

{
"jsonrpc" : "2.0",
"method" : "Announcement",
"params" : {
"message" : "QueueNextItem",
"sender" : "xbmc"
}
}

I cannot find why I was not able to get results querying about Artists. Any help is appreciated.

Thanks.


- giftie - 2011-09-06

keepsimple Wrote:Hi,
I am trying to use JSON RPC API talking to my XBMC v10.0 running on MacOS X. I tried the following calls but got result "null":

telnet localhost 9090

{"jsonrpc": "2.0", "method": "AudioLibrary.GetArtists", "params": {"fields": ["artistid", "label"]}, "id": 1}
{
"id" : 1,
"jsonrpc" : "2.0",
"result" : null
}

{"jsonrpc": "2.0", "method": "AudioLibrary.GetArtists","params":{}, "id":3}
{
"id" : 3,
"jsonrpc" : "2.0",
"result" : null
}
Check the output of JSONRPC.Introspect for the valid fields. If you drop the 'params":{} all together, you will get the output your looking for(artistid and label)

Quote:{"jsonrpc": "2.0", "method": "AudioLibrary.GetSongs", "id": 1}
{
"id" : 1,
"jsonrpc" : "2.0",
"result" : null
}

But I can play songs in XBMC and I can see the Announcements via JSON-RPC:

{
"jsonrpc" : "2.0",
"method" : "Announcement",
"params" : {
"message" : "QueueNextItem",
"sender" : "xbmc"
}
}

I cannot find why I was not able to get results querying about Artists. Any help is appreciated.

Thanks.

AudioLibrary.GetSongs needs params...


- keepsimple - 2011-09-06

giftie Wrote:Check the output of JSONRPC.Introspect for the valid fields. If you drop the 'params":{} all together, you will get the output your looking for(artistid and label)

I tried to drop the "params":{} , but still get result "null":

{"jsonrpc": "2.0", "method": "AudioLibrary.GetArtists", "id": 2}
{
"id" : 2,
"jsonrpc" : "2.0",
"result" : null
}


- dann0 - 2011-09-06

first question would have to be have you scanned media in to your library?

what you describe is exactly the response i get before adding a source to my library and scanning it.


- keepsimple - 2011-09-06

dann0 Wrote:first question would have to be have you scanned media in to your library?

what you describe is exactly the response i get before adding a source to my library and scanning it.

I did scan the library and I can play the songs in XBMC. Still cannot get results:


{"jsonrpc": "2.0", "method": "AudioLibrary.ScanForContent", "id": 1}
{
"id" : 1,
"jsonrpc" : "2.0",
"result" : "OK"
}
{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": {"fields": ["album_title"]}, "id": 1}
{
"id" : 1,
"jsonrpc" : "2.0",
"result" : null
}

{"jsonrpc": "2.0", "method": "AudioLibrary.GetArtists", "id": 1}
{
"id" : 1,
"jsonrpc" : "2.0",
"result" : null
}


- Montellese - 2011-09-06

keepsimple Wrote:I did scan the library and I can play the songs in XBMC. Still cannot get results:


{"jsonrpc": "2.0", "method": "AudioLibrary.ScanForContent", "id": 1}
{
"id" : 1,
"jsonrpc" : "2.0",
"result" : "OK"
}

That's not enough to get your albums, artists and songs into your library and you can also play songs in XBMC without adding them to the library. You need to add a music source to your library and tell it where to look for your audio files.

If JSONRPC does not return a result you haven't scanned your audio files into your library.


- keepsimple - 2011-09-07

Montellese Wrote:That's not enough to get your albums, artists and songs into your library and you can also play songs in XBMC without adding them to the library. You need to add a music source to your library and tell it where to look for your audio files.

If JSONRPC does not return a result you haven't scanned your audio files into your library.

Thanks for the assertion :-) Finally I found what it means by "into the library". It had to right click on the music item and select "Scan item to library".

I am sorry that I am asking some very basic questions. However, is this just me? I found this is very confusing. First, I am wondering what is the difference between "Add source" and "Scan to library"? Second, where can I look at my music library? It's clear that all sources are listed. But where is the "library"?

In any case, Thanks again for your help. Now my JSON-RPC is working :-)


- keepsimple - 2011-09-07

Just a follow-up, I found that I have to enable "Library mode" from a "hidden" left-bar menu to be able to see the music library. I thought it could be more straight forward...