【发布时间】:2013-05-07 14:22:25
【问题描述】:
我正在尝试通过 GET HTTP 请求从云中下载文件,并且在我的 REST 客户端(Chrome 的 Postman)中我得到了预期的结果,但是当我在 iOS 中传递请求时,我得到一个 NULL回复。可能是什么问题?
在我的 REST 客户端中,我将 URL 作为 http://myserver.com/api/download.json?filepath=/&fileid=document:1pLNAbof_dbXGn43GtMNafABMAr_peTToh6wEkXlab7U&filename=My Info.doc 传递,并带有一个用于授权密钥的标题字段,它工作得非常好。
在 iOS 中,如果我这样做:
[request setURL:[NSURL URLWithString:URLString]]; // I tried even to hardcode the
// URLString to be one of the
// working URLs from the Postman
// Client, doesn't work as well.
[request setHTTPMethod:@"GET"];
NSData* response = [NSURLConnection sendSynchronousRequest:request
returningResponse:&urlResponseList
error:&requestErrorList];
响应为空,我得到状态码 500。 任何人都知道如何使这项工作?谢谢。
【问题讨论】:
标签: ios json rest httprequest