我想通过使用将 JSON 字典作为参数传递uploadUrl
,但它给了我一个Unsupported Url
code-1002 错误。
当我在 Postman 上点击此 URL 时,它运行良好。如何使用 JSON 模型实现这一点?
NSString *uploadUrl =@"<Your host URL>";
[JSONHTTPClient postJSONFromURLWithString:uploadUrl params:nil
completion:^(NSDictionary *json, JSONModelError *err)
{
if(err == nil)
{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"success" message:@"uploaded" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
completionHanldler(json);
}
else
{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Failed" message:@"uploaded" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
NSMutableDictionary *errorDict=[[NSMutableDictionary alloc]init];
if(err.code==-1009)
[errorDict setObject:@"The Internet connection appears to be offline."forKey:@"error"];
else
[errorDict setObject:@"Error occurred. Please try again!"forKey:@"error"];
completionHanldler(errorDict);
}
}];