ASIHTTPRequest - PostData but GET Method
Is there 开发者_如何学Pythona way to see what request ASIHTTPRequest is making?
My code is:
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request appendPostData:[data dataUsingEncoding:NSUTF8StringEncoding]];
[request setRequestMethod:@"GET"];
[request addRequestHeader:@"Content-Type" value:@"application/json"];
And I'm trying to duplicate:
curl -X GET "http://www.myurl.com/_api/my/url" -H "Content-Type: application/json" -d {"api_key":"my_special_api_key_123"}
The curl works fine, but I can't get the ASIHTTPRequest to work properly.
Any ideas?
To debug the http request that is sent to the server you could use a http debugging proxy:
This thread lists some of the tools available on OSX (I haven't used any of them since I use Fiddler on a Windows box for debugging HTTP packets):
https://superuser.com/questions/42813/looking-for-http-debugging-proxy-for-mac-similar-to-fiddler-on-windows
Regarding what you are trying to do (send data with a GET request):
According to this discussion CFNetwork won't let you do it:
http://groups.google.com/group/asihttprequest/browse_thread/thread/918f11f1196a3b74?tvc=2&pli=1
If you really need to send data with a GET request you might have to use libcurl but I am not sure if it is available on iOS.
use ASIFormDataRequest for post params
精彩评论