tags:

views:

47

answers:

3

I have a general question. Using the NSMutableURLRequest object in the iPhone SDK, can I set the HTTPMethod to POST when retrieving data from a server?

+1  A: 

Normally you should either POST some data or GET some data, though issuing a POST and then fetching some data in a single request is perfectly valid.

Just to be clear, it is in fact quite common for a POST to return some data representing some sort of result message in response to the POST. Other uses (like piggy-backing an unrelated GET onto the POST) would be frowned upon.

Marcelo Cantos
A: 

If you are wanting to be HTTP / web standards compliant, you should use a GET when retrieving data. It will also depend on if the application you are talking to on the server will respond to a POST request for the given resource.

A: 

If you're willing to use third party libraries I can highly recommend ASIHTTPRequest:

http://allseeing-i.com/ASIHTTPRequest/

I've used this in library for http posts in a number of iPhone applications and been very happy with it.

Just to clarify: I'm not associated with these guys in any way, just like the library!

mad-dog-software