A best practice query

79 views
Skip to first unread message

Sean Farrow

unread,
Jan 16, 2018, 5:53:35 AM1/16/18
to api-...@googlegroups.com

Hi all,

 

I’m developing an api in which I have a resource for an individual user at the path /user/{id}.

I now need to allow the user to join one (and only one) organization, so I have an organizations endpoint hanging off the individual user resource.

Lets assume I set up the capability to post an organization id to the individual users organisations endpoint, the first time I return a created (201) but my question is, what should I semantically return for all subsequent post requests. I’m thinking either 200 as an organization exists for the user or 403 as the user can’t add another organization but was wondering which is technically correct as per the REST guidelines?

Any help appreciated.

Kind regards

Sean.

 

Lukas Rosenstock

unread,
Jan 16, 2018, 12:53:49 PM1/16/18
to api-...@googlegroups.com
Hello Sean,

I would definitely return an error code (i.e. 403) if the user tries to join a different organization to inform the API client that this is an invalid request if users can’t join a different organization.
If the user tries to rejoin the same organization, however, essentially nothing happens but this is not a request that clients should make so I believe both status codes are fine.

Lukas Rosenstock



-- 
You received this message because you are subscribed to the Google Groups "API Craft" group.
To unsubscribe from this group and stop receiving emails from it, send an email to api-craft+...@googlegroups.com.
Visit this group at https://groups.google.com/group/api-craft.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages