Monday 15 September 2014

Modelling operations in REST service -


I know that these types of questions have been asked before. My problem is solved and I want to know whether I am breaking comfort or HTTP principals anywhere.

In my system, I have a resource called member which supports GET / Post / Pet / Code> operation member's active Status of and disabled is. I need to model the operation of disabling the user. I understand why a bad idea from RES perspective would be

  POST api / member / john.smith / disable < / Code>  

I have read the solution to accept a resource that represents the request to deactivate a member, something like the following

  public class DisableMemberRequest { Public string username {get; Set;}}   

and then mail

  post api / disabled member request on the above resource   

Although this approach seems appropriate, I think it is not right in the case of a clean API interface. It may be controversial that the response to the above request should be 200 OK or 201 created or 202 approved .

I am thinking that I would like to drop this code on a new resource named disabled member and a PUT , that means that special member Should be disabled as below but I am not an expert and agree with those people I want to do this for a long time.

Edit

I am adding these details after interacting with fellow programmers on this page. The process of deactivating the member is not only about setting up a status flag on the member. There are other workflows that need to be triggered if a member is disabled.

In a way that I like to work in a way that defines a resource that is disabled The set represents the members. To disable the member, you can add that member to a group of disabled members. It may look something like this.

  Post / API / Passive Memory Content-Type: Text / Yuri-List http://example.org/api/members/john.smith   

If you want to reverse the operation, you can

  POST / api / ActiveMembers content-type: text / yuri-list http://example.org/ API / member / Jyotsith   

From this perspective, the advantage of this fact is that it is a completely natural thing to do GET / api / disabled mames . In addition, by using text / uri-list it becomes easy to deactivate / re-activate a group of members at the same time.

No comments:

Post a Comment