0

I'm working on REST API, and I trying to understand whether this looks legit in terms of REST.

I've players which using some mobile app with a login mechanism, So the question is, if the player needs to update some attribute on his resource, How the URL & PARAMS should looks like:

Option #1:

PUT /api/players/59/
PARAMS { some_attribute: "some_value" }

Option #2:

PUT /api/players/self
PARAMS { some_attribute: "some_value" }

The thing is, that the player doing the call with authentication, so it looks odd that he needs to send his id, it feels like he can send update on some other id, so when he sends 'self' it looks more suitable but uglier. What's the REST point of view here?

Or maybe another option?

Yarin Gold
  • 489
  • 1
  • 4
  • 17

1 Answers1

0

You should use first option But in first option, request additional parameter like authentication_token to verify the user and user is updating his information only.

This gist will help you in authenticating user

https://gist.github.com/josevalim/fb706b1e933ef01e4fb6

It shows 2 method for authenticating user while communicating with API

Kalpesh Fulpagare
  • 1,309
  • 10
  • 18