1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-29 23:12:39 +01:00

Fixed: Error updating providers with ID missing from JSON

This commit is contained in:
Bogdan 2024-10-08 01:27:22 +03:00 committed by GitHub
parent 3828e475cc
commit c435fcd685
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -86,9 +86,16 @@ namespace Sonarr.Api.V3
[RestPutById]
[Consumes("application/json")]
[Produces("application/json")]
public ActionResult<TProviderResource> UpdateProvider([FromBody] TProviderResource providerResource, [FromQuery] bool forceSave = false)
public ActionResult<TProviderResource> UpdateProvider([FromRoute] int id, [FromBody] TProviderResource providerResource, [FromQuery] bool forceSave = false)
{
var existingDefinition = _providerFactory.Find(providerResource.Id);
// TODO: Remove fallback to Id from body in next API version bump
var existingDefinition = _providerFactory.Find(id) ?? _providerFactory.Find(providerResource.Id);
if (existingDefinition == null)
{
return NotFound();
}
var providerDefinition = GetDefinition(providerResource, existingDefinition, true, !forceSave, false);
// Compare settings separately because they are not serialized with the definition.
@ -105,7 +112,7 @@ namespace Sonarr.Api.V3
_providerFactory.Update(providerDefinition);
}
return Accepted(providerResource.Id);
return Accepted(existingDefinition.Id);
}
[HttpPut("bulk")]