Sonarr getting 401 unauthorized when sending json updates to kodi

hello everyone, recently made the switch from sickbeard to sonarr. i’m having an issue where it is unable to send the jsonrpc request to kodi for it to update the library. it comes back with a 401 unauthorized error.

i am able to submit url-based json requests with no issues. i can access kodi’s webgui and also i have a pp script for movies that is able to notify kodi. any ideas? i know json works, ip and port is good based on url-based json requests working.

when i click on test from the connections menu nothing happens per both sonarr trace logs and kodi debug logs.

example logfile http://pastebin.com/eu7DhuKT

You’re using username only on Kodi (I skimmed the IRC logs)?

I’m wondering if the authentication header isn’t set when only one is set in Sonarr, I’d have to do some testing to find out if thats the case though. I know it will only send it if the username is set in Sonarr, but it may fail to send if the password is not set too.

other json requests work with no login needed, also i dont need a login to access webgui for kodi. but i do have a username set per advancedsettings.xml but no password.

i actually did find something… if i set on grab and on upgrade to no (only on download selected), clicking test won’t do anything per the trace logs, but it’ll say test completed. if i put them to yes, only then do i see it doing something in the logs, and it says test failed.

15-4-9 19:04:44.3|Debug|XbmcService|Determining version of XBMC Host: 192.168.1.2:8081
15-4-9 19:04:44.3|Debug|RestSharpExtensions|Validating Responses from [POST] [http://192.168.1.2:8081/jsonrpc] status: [Unauthorized]
15-4-9 19:04:44.3|Warn|RestSharpExtensions|[POST] [http://192.168.1.2:8081/jsonrpc] Failed. [Unauthorized]
15-4-9 19:04:44.4|Debug|XbmcService|REST request failed: [401] [POST] at [http://192.168.1.2:8081/jsonrpc]

NzbDrone.Core.Rest.RestException: REST request failed: [401] [POST] at [http://192.168.1.2:8081/jsonrpc]
at NzbDrone.Core.Rest.RestSharpExtensions.ValidateResponse (IRestResponse response, IRestClient restClient) [0x00000] in :0
at NzbDrone.Core.Rest.RestSharpExtensions.ExecuteAndValidate (IRestClient client, IRestRequest request) [0x00000] in :0
at NzbDrone.Core.Notifications.Xbmc.XbmcJsonApiProxy.ProcessRequest (IRestRequest request, NzbDrone.Core.Notifications.Xbmc.XbmcSettings settings, System.String method, System.Collections.Generic.Dictionary2 parameters) [0x00000] in <filename unknown>:0 at NzbDrone.Core.Notifications.Xbmc.XbmcJsonApiProxy.GetJsonVersion (NzbDrone.Core.Notifications.Xbmc.XbmcSettings settings) [0x00000] in <filename unknown>:0 at NzbDrone.Core.Notifications.Xbmc.XbmcService+<>c__DisplayClass2.<GetJsonVersion>b__0 () [0x00000] in <filename unknown>:0 at NzbDrone.Common.Cache.Cached1[NzbDrone.Core.Notifications.Xbmc.Model.XbmcVersion].Get (System.String key, System.Func1 function, Nullable1 lifeTime) [0x00000] in :0
at NzbDrone.Core.Notifications.Xbmc.XbmcService.GetJsonVersion (NzbDrone.Core.Notifications.Xbmc.XbmcSettings settings) [0x00000] in :0

15-4-9 19:04:44.4|Debug|XbmcService|Version is: 0.0.0
15-4-9 19:04:44.5|Error|XbmcService|Unable to send test message: Verion received from XBMC is invalid, please correct your settings.

NzbDrone.Core.Notifications.Xbmc.InvalidXbmcVersionException: Verion received from XBMC is invalid, please correct your settings.
at NzbDrone.Core.Notifications.Xbmc.XbmcService.Test (NzbDrone.Core.Notifications.Xbmc.XbmcSettings settings) [0x00000] in :0

15-4-9 19:04:44.6|Trace|NzbDroneErrorPipeline|Handling Exception
15-4-9 19:04:44.6|Warn|NzbDroneErrorPipeline|Invalid request Validation failed:
– Unable to send test message

Ran a couple tests against Kodi 14.2 Beta1. With just a username configured on Kodi’s side I can send requests without a username or with any username I want set in Sonarr.

As soon as I add a password to Kodi’s WebUI I need to supply the correct credentials or it fails

  • No username/password - Connection fails (doesn’t even get a 401)
  • No password - Connection fails with 401
  • Incorrect username/password - Connection fails with 401
  • Correct username/password - successful test

The fact that it doesn’t run the test when on grab is disabled is a bug that has already been fixed in the latest develop version.

I’m not seeing any indication that this is a problem on Sonarr’s side though.

selecting the other options to get something in the logs and an actual error made it easier to see what was the problem. i was playing with all different logins and hostname vs ip and it seems to be working now. before it wasn’t doing anything no matter what combination of logins i used, so it was hard to see where the actual issue was…

there is a connection between sonarr and kodi now! won’t find out if it actually updates my library until tonight though.