Fixed: Use route Id for PUT requests if not passed in body
This commit is contained in:
parent
528feb14c9
commit
becc567ff7
|
@ -8,6 +8,7 @@ using NzbDrone.SignalR;
|
||||||
using Sonarr.Http;
|
using Sonarr.Http;
|
||||||
using Sonarr.Http.Extensions;
|
using Sonarr.Http.Extensions;
|
||||||
using Sonarr.Http.REST;
|
using Sonarr.Http.REST;
|
||||||
|
using Sonarr.Http.REST.Attributes;
|
||||||
|
|
||||||
namespace Sonarr.Api.V3.Episodes
|
namespace Sonarr.Api.V3.Episodes
|
||||||
{
|
{
|
||||||
|
@ -47,9 +48,9 @@ namespace Sonarr.Api.V3.Episodes
|
||||||
throw new BadRequestException("seriesId or episodeIds must be provided");
|
throw new BadRequestException("seriesId or episodeIds must be provided");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("{id}")]
|
[RestPutById]
|
||||||
[Consumes("application/json")]
|
[Consumes("application/json")]
|
||||||
public IActionResult SetEpisodeMonitored([FromBody] EpisodeResource resource, [FromRoute] int id)
|
public ActionResult<EpisodeResource> SetEpisodeMonitored([FromRoute] int id, [FromBody] EpisodeResource resource)
|
||||||
{
|
{
|
||||||
_episodeService.SetEpisodeMonitored(id, resource.Monitored);
|
_episodeService.SetEpisodeMonitored(id, resource.Monitored);
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,12 @@ namespace Sonarr.Http.REST
|
||||||
|
|
||||||
foreach (var resource in resourceArgs)
|
foreach (var resource in resourceArgs)
|
||||||
{
|
{
|
||||||
|
// Map route Id to body resource if not set in request
|
||||||
|
if (Request.Method == "PUT" && resource.Id == 0 && context.RouteData.Values.TryGetValue("id", out var routeId))
|
||||||
|
{
|
||||||
|
resource.Id = Convert.ToInt32(routeId);
|
||||||
|
}
|
||||||
|
|
||||||
ValidateResource(resource, skipValidate, skipShared);
|
ValidateResource(resource, skipValidate, skipShared);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue