From 7d9db5425f569c30d186e5c36e55b204be0585be Mon Sep 17 00:00:00 2001 From: jzinkweg Date: Thu, 8 Apr 2021 16:47:16 +0200 Subject: [PATCH] Add consumes annotation to form endpoints Updating Jersey/jax-rs broke both form endpoints. Explicitly stating the endpoint expects form data fixes it. --- src/de/michaelkuerbis/presenter/rest/CronREST.java | 3 +++ src/de/michaelkuerbis/presenter/rest/StartREST.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/de/michaelkuerbis/presenter/rest/CronREST.java b/src/de/michaelkuerbis/presenter/rest/CronREST.java index 445797c..69b143b 100644 --- a/src/de/michaelkuerbis/presenter/rest/CronREST.java +++ b/src/de/michaelkuerbis/presenter/rest/CronREST.java @@ -4,6 +4,7 @@ import java.util.Vector; import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.FormParam; import javax.ws.rs.GET; @@ -11,6 +12,7 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import net.redhogs.cronparser.CronExpressionDescriptor; @@ -29,6 +31,7 @@ public class CronREST { private HttpServletRequest webRequest; @POST + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Path("/add/{target}") public Response addChromecast(@PathParam("target") String target, @FormParam("name") String name, @FormParam("url") String url, diff --git a/src/de/michaelkuerbis/presenter/rest/StartREST.java b/src/de/michaelkuerbis/presenter/rest/StartREST.java index 1c40ea1..7eb8719 100644 --- a/src/de/michaelkuerbis/presenter/rest/StartREST.java +++ b/src/de/michaelkuerbis/presenter/rest/StartREST.java @@ -3,10 +3,12 @@ import java.io.IOException; import java.security.GeneralSecurityException; +import javax.ws.rs.Consumes; import javax.ws.rs.FormParam; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import su.litvak.chromecast.api.v2.Application; @@ -20,6 +22,7 @@ public class StartREST { @POST + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Path("/{ip}") public Response startCast(@PathParam("ip") String ip, @FormParam("url") String url, @FormParam("reload") int reload) {