How do I redirect a GET REST service to a POST REST service. I am using resteasy and I tried
Response.seeOther
Response.temporaryRedirect
From what I see, both these methods could make GET requests only.
Is there a way to make POST calls using the above APIs? Redirect is important to me because I want the browser to be aware of the new URL.
Short answer: Don't do it.
GET
and POST
have well defined semantics. A GET
is intended for reading resources whereas a POST
is usually used to create or update a resource. See also this question.
It does not make sense to redirect from a GET
to a POST
because a user should be sure that he doesn't change the state of a resource if he uses a GET
.
For the other way round there's a common pattern called POST-Redirect-GET (PRG) where the user is redirected to a new resource after he created one per POST
. One reason for this pattern is to avoid a double POST
if the user reloads a page.