嗨,我正在尝试发出 POST 请求
我的代码:
NSURL *url = [NSURL URLWithString:urlString];
__weak ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setDelegate:self];
[request setRequestMethod:@"POST"];
[request setPostValue:@"JustinBieber" forKey:@"fname"];
[request setCompletionBlock:^{
NSString *result = [request responseString];
NSDictionary *dict = [result JSON];
NSLog(@"dict -%@",dict);
}];
[request setFailedBlock:^{
NSLog(@"error %@",[request error]);
}];
[request startAsynchronous];
当我运行我的代码时,它返回一个(空)值。我的 urlString 是正确的,请求也没有给我错误。我已经在网上尝试过并返回 {"status":"success"} (它将返回状态为成功或失败的字典)。