David Faiz David Faiz -4 years ago 95
Node.js Question

REST API - where to pass ID parameter? in URL or in header

I wrote a small web service with REST API and after reading a few tutorials I cannot come to a conclusive answer.

If I wish to pass a user id to the REST API, should I pass it in the URL like so:

Or like so:

If I were to use the second one, how will I be able to retrieve the user ID from the URL? I'm using nodejs + express.

Please advise.

Answer Source

The second option you mentioned is the best way. Or at least the most conforming to the REST design.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download