ASIHTTPFormDataRequest- "Unable to create request (bad url?)"
I have the following requirement to call a service using an ASIHTTPRequest with a POST method call. When I execute the request I get the following error:
errorError Domain=ASIHTTPRequestErrorDomain Code=5 "Unable to create request (bad url?)" UserInfo=0x790b490 {NSLocalizedDescription=Unable to create request (bad url?)}
And heres my code:
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:SampleURL]];
[request addPostValue:@"emailid" forKey:username.text];
[request addPostValue:@"password" forKey:password.text];
[request addPostValue:@"first_name" forKey:first_name];
[reque开发者_Python百科st addPostValue:@"last_name" forKey:last_name];
[request addPostValue:@"option" forKey:@"userSignup"];
request.delegate = self;
[request startSynchronous];
Can anyone help me on this?
NSString *safestring=[strUrl stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSURL *url= [NSURL URLWithString:safestring];
[request addPostValue:@"emailid" forKey:username.text];
Shouldn't that be in the opposite order: [request addPostValue:username.text forKey:@"emailid"];
Same for the rest...
It looks like that 'sampleURL' has some issue. What is the data type of sampleUL? it should be NSURL. Also what is in sampleURL when this piece of code is executed.
精彩评论