Reputation: 2464
My request is
request_ = [[ASIFormDataRequest requestWithURL:requestUrl] retain];
[request_ setDelegate:self];
[request_ setRequestMethod:@"GET"];
[request_ setTimeOutSeconds:HTTP_TIME_OUT];
[request_ startAsynchronous];
But the response from the server is
HTTP Status 405 - Request method 'GET' not supported. The specified HTTP method is not allowed for the requested resource (Request method 'GET' not supported).
Please note that the url doesn't have any "GET" parameters along with it even though it is a get request. The thing is I am getting the proper response from the server when simply I take the request URL in a browser or when I call it using "HttpRequester"(a Firefox add-on to test http requests - well I'm sure you know that). What could have went wrong?
Thanks in advance.
Balu
Upvotes: 2
Views: 2449
Reputation: 21
Seems it is a server side issue. Please verify if all the header parameters as required by the server are there in request.
Upvotes: 1
Reputation: 2464
Solved it. It was because of the absence of the header parameter "Accept" in requests that have been made. Once it was added, everything worked like a charm. Also replaced ASIFormDataRequest with ASIHTTPRequest(that one was a silly mistake).
Upvotes: 1
Reputation: 53082
For GET
requests, use ASIHTTPRequest
.
ASIFormDataRequest
is for POST
requests.
However, if all you need is a simple GET
request, why bother with ASI? You can do this in a dispatch_async
block:
dispatch_async(<some_queue>, ^{
NSError * error = nil;
NSString * response = [NSString stringWithContentsOfURL: stringWithContentsOfURL: requestUrl error: &error];
[self performSelectorOnMainThread: @selector(processResult:) withObject: response waitUntilDone: NO];
});
Upvotes: 2
Reputation: 9481
why you create a ASIFormDataRequest
aka POSTRequest and set the RequestMethod
to GET?
If you want to make a GET Request use ASIHTTPRequest
instead.
Upvotes: 0