mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-02-14 12:20:55 +02:00
Fixed: Error updating providers with ID missing from JSON
This commit is contained in:
parent
3828e475cc
commit
c435fcd685
@ -86,9 +86,16 @@ namespace Sonarr.Api.V3
|
|||||||
[RestPutById]
|
[RestPutById]
|
||||||
[Consumes("application/json")]
|
[Consumes("application/json")]
|
||||||
[Produces("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);
|
var providerDefinition = GetDefinition(providerResource, existingDefinition, true, !forceSave, false);
|
||||||
|
|
||||||
// Compare settings separately because they are not serialized with the definition.
|
// Compare settings separately because they are not serialized with the definition.
|
||||||
@ -105,7 +112,7 @@ namespace Sonarr.Api.V3
|
|||||||
_providerFactory.Update(providerDefinition);
|
_providerFactory.Update(providerDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Accepted(providerResource.Id);
|
return Accepted(existingDefinition.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("bulk")]
|
[HttpPut("bulk")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user