0

How do I redirect a GET REST service to a POST REST service. I am using resteasy and I tried

  1. Response.seeOther

  2. 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.

Yasser
  • 575
  • 1
  • 4
  • 19

1 Answers1

4

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.

Community
  • 1
  • 1
lefloh
  • 10,653
  • 3
  • 28
  • 50
  • 1
    I agree with you. I got deep in the weeds that I didnt think about it. I should think differently to solve my problem. – Yasser Nov 03 '15 at 17:25