David Tamrazov
David Tamrazov

Reputation: 597

When would I use the request body in a POST method? iOS

I'm unsure as to when I would fill in the body of an Http POST request. I've read that the body is where you pass parameters such as "para1=value1&para2=value2" to the POST request, but why would I need to do this? If I'm simply trying to post some data to a specified location in my servers, why would I pass in extra parameters in the body?

Upvotes: 0

Views: 49

Answers (1)

SiKing
SiKing

Reputation: 10329

In order to be RESTfull, all parameters - passed either in the URL or as body - are optional. REST does not require a body be passed for a POST operation.

The choice between using URL parameters or body parameters is an architecture decision. For complicated objects, you will probably not be able to express them using only URL parameters. Note that a combination of both URL and body parameters is also valid.

The only thing you should adhere to is that GET, PUT and DELETE are idempotent, whereas POST is not. More information is available on Wikipedia and other sources on the net.

Upvotes: 1

Related Questions