"error": "Unauthorized" after update

Sonarr version (exact version): 2.0.0.4855
Mono version (if Sonarr is not running on Windows): 5.0.1.1
OS: Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-107-generic x86_64)
((Debug logs)):
(Make sure debug logging is enabled in settings and post the full log to hastebin/pastebin/dropbox/google drive or something similar, do not post them directly here)
Description of issue: Hi Guys, I’ve just updated to 2.0.0.4855 and now my api calls are getting the “error”: “Unauthorized” response.

I have a GO script which is making the api calls, which a friend built for me as I couldn’t figure out making the calls directly from python. (https://github.com/kgigitdev/gonarr) .

The idea is that PlexPy calls this script when an episode is watched on my Plex server, and instructs Sonarr to start searching for any missing episodes. It does so using the api/series and api/command

This has been working perfectly for months, but I noticed from the logs that after the update its no longer working.

Here is the output from the GO script:

https://pastebin.com/Ex2XaMLm

I found this in one of the debug logs of Sonarr also, but not sure if its related:

17-7-8 08:49:23.8|Debug|Api|[GET] /api/queue?sort_by=timeleft&order=asc: 200.OK (3 ms)
17-7-8 08:50:40.4|Debug|Api|[GET] /api/series: 303.SeeOther (0 ms)
17-7-8 08:50:40.5|Debug|Api|[GET] /api/series: 401.Unauthorized (0 ms)

I’ve checked the api key and it seems to match perfectly. I haven’t changed anything in any scripts. The only thing I did was update to the latest Sonarr.

Any advice much appreciated.

17-7-8 08:50:40.4|Debug|Api|[GET] /api/series: 303.SeeOther (0 ms)

That might be the issue, if it’s being redirected the POST wouldn’t complete properly, if you’re using a URL Base in Sonarr you’ll want to prefix that to /api in the api_prefix option in Gonarr I believe.

aah markus you’re a legend. That was it.

So was this because of a change on your side in the new version? Because i’ve always had the URL base set in Sonarr but never had to use it for the api. Just curious :slight_smile:

Dunno, but it looks like your client doesn’t preserve the X-Api-Key header when it follows the redirect.

Yeah I have no idea about GO. I’d prefer to have this all in Python but couldn’t figure out the curl command, and my mate kindly offered to build the GO script.

I’d love to have a simple python command to take care of this so that I can troubleshoot more easily in the future. Any chance of you giving me the commands to 1) Set all episodes of a specific season to monitored, 2) Search for all wanted episodes of that season?

I’ve tried to read the docs but honestly I always get stuck on the authentication bit.

Ok, I understand you guys not wanting to spoon feed each user who asks for specific commands :slight_smile:

I think what would really help however would be if you could put some generic examples in your wiki, for common methods of accessing and performing commands of the api. I’m sure this would be highly beneficial for the community, and would prevent n00bs like me from asking for so much personalised attention. Any chance of this?

You mean https://github.com/Sonarr/Sonarr/wiki/API ?

Lol taloth… I’m not that blind! I meant an example in python etc! It’s curl and json that’s got me confused and a few examples of using these API commands inside python would be awesome.

I’m not fluent with python, so I just googled ‘python rest api example’ and got a decent example. This isn’t rocket science. It’s a rest api, the authentication is a query param or http header. That’s all explained in the wiki and should be enough, if someone doesn’t know what a http header is and unable to google it, then the api is not something for him.
I’m not saying that applies to you, but I’m pointing out the expected level of expertise and know-how.
The current api docs aren’t very readable, but it’s got the pertinent information and i’m not going to invest a big chunk of my time in improving it.

Btw. use your browser developer console, coz the Sonarr UI uses the api itself.

Taloth, I completely understand. Your post is warranted and I admire your restraint.

2 things you just said helped me immensely. googling rest api, and using the developer console which I really never even thought about.

Many thanks to you and the team for your continued commitment to Sonarr.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.