Reputation: 2329
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];
[request addPostValue:@"last_name" forKey:last_name];
[request addPostValue:@"option" forKey:@"userSignup"];
request.delegate = self;
[request startSynchronous];
Can anyone help me on this?
Upvotes: 0
Views: 1611
Reputation: 3925
[request addPostValue:@"emailid" forKey:username.text];
Shouldn't that be in the opposite order: [request addPostValue:username.text forKey:@"emailid"];
Same for the rest...
Upvotes: 1
Reputation: 1694
NSString *safestring=[strUrl stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSURL *url= [NSURL URLWithString:safestring];
Upvotes: 1
Reputation: 6016
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.
Upvotes: 0