I am creating a system that requires a user to validate using a SMS Code in order to create an account. The system will have a RESTful API to access the other resources of the system but I am wondering if the account creation stage is suitable for a RESTful API. The high level sequence that I am trying to achieve is:
If I was to express this using REST Principles I would implement is as follows:
where RegistrationItem would look like:
class RegistrationItem
{
public string SmsCode {get;set;}
public int RegistrationId {get;set;}
public string PhoneNumber {get;set;}
}
Does this seem a reasonable design or do account creation and RESTful API’s not normally co-exist? I notice that most API’s I looked at (facebook, foursquare, twillio) don’t seem to support it.
3
Answers
There’s no reason you couldn’t do account creation from a RESTful API. I might name things differently, but the flow seems reasonable.
Since you asked, I would probably do:
The response would have the id. If you’re striving for HATEOAS, then it should also have a URI for user creation, either as a Link in the header or as part of the response. Then to create the user,
and make it return a new user instance. If these APIs can get called from a browser, you should strongly consider using the Post-Redirect-Get pattern.
REST models get, create, update and delete operations. Register is a type of create operation. So, yes REST is suitable–unless there’s some other criteria or question you have.
Yes. Nelibur could really help you to create appropriate API.
Good tutorial:http://www.codeproject.com/Articles/712689/Building-RESTful-Message-Based-Web-Services-with-W
Hope this help;