• Post Reply Bookmark Topic Watch Topic
  • New Topic

REST GET or POST

 
Sangel Kapoor
Ranch Hand
Posts: 162
1
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello JavaRanchers

Background :
When a user registers on our website with his details, we send SMS with random verification code . Now user need to put that code on the webpage and submits in order to verify his mobile number with us.

Problem:
I need to make a REST service which checks the SMS Verification code submitted by a user.

Solution :
I am doing it by GET call with query parameter as Verification code. /{userID}/verify-email?verificationCode=12121212

Query :

Is it right in accordance to REST standards or should I employ something else like POST for it.

Regards



 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that the site remembers the verification, this is a POST operation since it modifies a resource.

Bill
 
Radhakrishna Sharma Gorenta
Ranch Hand
Posts: 63
Google App Engine Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's better to use POST in this case.
 
Sangel Kapoor
Ranch Hand
Posts: 162
1
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what would be the best way to indicate REST resource for this

/{userID}/verify-email

or

/{userID}/ with post body
{
code: "XXX"
}


Also in accordance to this blog post http://www.chrislondon.co/appropriate-restful-handling-of-password-reset-and-email-verification/
PUT seems more reasonable than POST.
 
Radhakrishna Sharma Gorenta
Ranch Hand
Posts: 63
Google App Engine Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the second one is the recommended one.

/{userID}/ with post body
{
code: "XXX"
}
 
Daniel Spiess
Greenhorn
Posts: 3
Google App Engine Java Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not so sure a POST is the right solution here. Ultimately the resource you're changing is the user. You're making the user go from a not validated state to a validated state. In both states, the user exists. POST is used for creating a resource, and you're supposed to include the entire resource.

I think what you want is some type of PUT.

PUT user/{id} with XML including the validation code. The call would return a user in the validated state if the code works, and an error otherwise.

My $0.02
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!