• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

REST GET or POST

 
Ranch Hand
Posts: 162
1
Android Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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



 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assuming that the site remembers the verification, this is a POST operation since it modifies a resource.

Bill
 
Ranch Hand
Posts: 63
Spring Java Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Spring Java Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the second one is the recommended one.

/{userID}/ with post body
{
code: "XXX"
}
 
Greenhorn
Posts: 3
Objective C Java Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic