我想送POST請求沒有身在IOS如何在ios中發送沒有正文的json POST請求?
我試過如下
NSString *url = [NSString stringWithFormat:@"Some URL"];
NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",url]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:URL];
[request addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPMethod: @"POST"];
[NSURLConnection connectionWithRequest:request delegate:self];
我提示以下錯誤:
Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo=0x15d62ed0
NSLocalizedDescription=Could not connect to the server.,
NSUnderlyingError=0x15e522a0 "Could not connect to the server."}
「Some URL 「不是一個有效的URL!你有沒有嘗試向其他程序發佈一些內容以確保其正常工作? – folkol 2014-09-20 09:13:26
嘿@Madhu檢查我的答案。,,,, – 2014-09-20 09:21:42