Zach
Zach

Reputation: 1351

REST API Best Practices: Where should data be passed in POST requests? Parameters, Endpoint, Body?

I know this is a fairly general question, but I've searched around and can't really find any best practices or guidelines about API design specifically for accepting data in POST/PUT requests.

So, what are the best practices to follow when designing your API and are there any rules or guidelines that you follow?

Thanks!

Upvotes: 0

Views: 334

Answers (1)

Evert
Evert

Reputation: 99728

Generally, when data is POSTed to a HTTP server, the relevant data related to what you're posting will be in the body.

I say generally because there are exceptions.

This is even more so the case with PUT, the data really should be in the body. If there is no body in a PUT request, the meaning of the request is: "please replace this resource with a 0-byte resource".

Upvotes: 1

Related Questions