mirror of
https://github.com/Sonarr/Sonarr
synced 2025-12-06 08:28:37 +01:00
Fixed: Error updating providers with ID missing from JSON
This commit is contained in:
parent
3828e475cc
commit
c435fcd685
1 changed files with 10 additions and 3 deletions
|
|
@ -86,9 +86,16 @@ public ActionResult<TProviderResource> CreateProvider([FromBody] TProviderResour
|
|||
[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 @@ public ActionResult<TProviderResource> UpdateProvider([FromBody] TProviderResour
|
|||
_providerFactory.Update(providerDefinition);
|
||||
}
|
||||
|
||||
return Accepted(providerResource.Id);
|
||||
return Accepted(existingDefinition.Id);
|
||||
}
|
||||
|
||||
[HttpPut("bulk")]
|
||||
|
|
|
|||
Loading…
Reference in a new issue