Sonarr 2.0.0.4323 - api/episode method Put error 500

Sonarr version (exact version): 2.0.0.4323
Mono version (if Sonarr is not running on Windows):
OS: Windows 10.0.14393 x64
((Debug logs)): sonarr.debug.txt
Description of issue:
Hello,

since the last update, calling the api/episode with method PUT (to update an episode monitored status from True to False) returns the error 500 and the logs returns this :

Request Failed: Error converting value “@{id=4; name=HDTV-720p}” to type ‘NzbDrone.Core.Qualities.Quality’. Path ‘episodeFile.quality.quality’, line 18, position 78.

The script is in powershell using Invoke-RestMethod, the body is the episode informations retrieved with method Get on api/episode (with just the modification on monitored) in json format

Best regards

@{...} is a powershell object, not json. So the PUT is definitely incorrect.

I convert the object to json before.

This used to work with the previous version of sonarr…

Also I don’t understand the error in the log, because there is no such informations in the episode information

Maybe the error is not related to my request, but only htis one :

16-9-12 22:15:20.9|Debug|Api|[PUT] /api/episode: 500.InternalServerError (15 ms)

Euh, there probably is. Just hook up Fiddler or something and intercept the http content and see for yourself.

The json seems correct but in order to make it work I had to remove some informations from the episode :

episodeFile.quality
series.seasons
series.images

Now it works…

Can someone confirm there is something wrong with the api put

the way I try to update monitored status of an episode :

  • getting all episodes for a serie in order to get the episode id I want tu update
  • using API GET/{id} to retrieve the episode informations (as the documentation says : https://github.com/Sonarr/Sonarr/wiki/Episode#put)
  • using api PUT with object in body (converted to json)
  • Then I have an error if I don’t remove (episodeFile.quality, series.seasons, series.images)

Sorry if I do things baddly, I’m totally new to the world of REST API

Thank you in advance

The problem is likely in your powershell code, incorrectly serializing json. But you need to show us the actual HTTP call, both the GET/{id} and PUT.
Fiddler would be perfect for that, the inspector shows the http call including headers and contents.

And yes, PUT api/episode works fine.

If you already have the list of episodes you don’t need to get the single episode to post it back to the server, if you need the episode file you can fetch the episode file using the episodeFileId on the episode.

Ok, thank you for your answers,

I’ll give it a try with Fiddler this evening.

Sorry I’m a newbie, but how to fetch the episode file using the episodeFileId. I can’t find help in the API documentation

Thank you in advance

The method is similar to getting an episode by its ID.

Ok, sorry my question was how to PUT episodefile as there is no documentation and this morning I was not awake, so I can now put episodeFIle but the field I want to update (monitored) is not in the episodefile.

Is it possible to update only one field instead of the whole episode ?

Regards

You don’t PUT an episodeFile to update the monitored status of the episode. That is why I said if you need the episode file, you can get it with the episodeFileId, if you’re trying to update the monitored status for the episode don’t even bother fetching the episode file, you don’t need it.

You’d get the list of episodes, pull the one you want to update out of the list of them and then PUT that to the server after changing the monitored status.

No, it’s not possible.

Thank you.

here are the results from fiddler :
GET_id.saz
PUT_episode KO.saz
PUT_episode OK.saz

I did some test :
I tried with an old version 2.0.0.3732 and it works…

So, I re-tried with the last one and here are my results :

  • When the episode contains an episodeFile (aka when I have the episode on my HDD), it fails (see file PUT_episode KO.saz)
  • When the episode does not contains an episodeFile it works
    So, I tried by setting episodeFile of my object episode (retrieved with GET/{id}, see file GET_id.saz) to “” and it works (see file PUT_episode OK.saz)

The episode object is convertged to json with the native powershell command ConvertTo-Json

Regards

GET_id.saz:


PUT_episode KO.saz:

So, something in powershell is messing it up. it’s as simple as that. Possibly the -Depth parameter for the ConvertTo-Json function.

perfect !
I changed the depth to 3 and now it works.

Thank you for the help, now I know more about json, rest API and fiddler i.

So it means there is more control in the last version because in previous version, badly formatted json was accepted…

Anyway, thank you in very much and sorry for the loss of time.

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