How to determine the Http Method type being implemented for web service API
How to determine the Http Method type being implemented for web service API
- Subject: How to determine the Http Method type being implemented for web service API
- From: Omkar Ramtekkar <email@hidden>
- Date: Mon, 24 Jun 2013 06:05:20 +0000
- Thread-topic: How to determine the Http Method type being implemented for web service API
Hello,
I'm working on a project, where in I need to get the data from server through RESTful web services.
Server side people have implemented a few web services. I need to use those methods, but I'm not sure which http method to use "Get" or "POST".
If I use "GET" as http method and if the server web service is being implemented in "POST" then I get 404 or similar http error code.
Is there any way to find out the http method type being implemented for a web server API?
Right now I'm using a BOOL flag to determine which Http method to use. The flag is being set from outside.
NSMutableURLRequest *urlRequest = nil;
if (_usePostMethod)
{
urlRequest = [[NSMutableURLRequest alloc] initWithURL:self.serverURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0f];;
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setHTTPBody:[restMessage.message dataUsingEncoding:NSUTF8StringEncoding]];
}
else
{
urlRequest = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", self.serverURL, restMessage.message]]
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0f];
[urlRequest setHTTPMethod:@"GET"];
}
I wanted to get rid of this BOOL _usePostMethod variable.
Thanks and Regards
Omkar Ramtekkar | Module Lead - Collaboration BU
email@hidden<mailto:email@hidden> | Cell: +91-9730162294 | Tel: +91-712-398-6261
Persistent Systems Ltd. | 20 Glorious Years | www.persistentsys.com<http://www.persistentsys.com/>
DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden