0

I have referenced stackexchange's RESTful APIs.

From this, I have one situation that makes me confused.

I have this API:

/users/{user_id}/followings

On this API,

GET means get the all follwing user lists of user_id. This is good.

But, when I want to add one follwing user(this is kind of adding following user like instagram or facebook), should I have to use above REST API with PUT?

I'm confused using PUT with above API. Because, as above API means all follwing lists of user_id, if I use this API to PUT, it means put the all follwing users to user_id, not one following users.

Is it just OK to use above API to add(using put method) one following user to user_id?

Alexandru Marculescu
  • 5,569
  • 6
  • 34
  • 50
user7159879
  • 637
  • 2
  • 8
  • 14
  • 1
    Use GET to get the data, POST to add new data, PUT to update data, DELETE to remove data – B001ᛦ Nov 21 '16 at 13:13
  • @bub yeah, I know that mechanism. But what I mean is `/users/{user_id}/followings` means **all**, not the only **one**. So my question is that 'is it ok to use this API to add **one** following user to `user_id`'. – user7159879 Nov 21 '16 at 13:16

1 Answers1

0

You can just POST a new user to /users/{user_id}/followings. I wouldn't PUT on a list - you can use a PATCH add if you want to go down that path - see this link.

Alexandru Marculescu
  • 5,569
  • 6
  • 34
  • 50