gpt4 book ai didi

ios - 请求失败 : unacceptable content-type: application/osm3s+xml

转载 作者:行者123 更新时间:2023-11-29 02:20:57 26 4
gpt4 key购买 nike

我正在尝试向 OpenStreetMap api 发送请求,但我仍然没有成功。请帮我看看哪里不对。

我的方法:

NSString *url = @"http://api.openstreetmap.fr/xapi?node[name=London]";

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/osm3s+xml"];
[manager setResponseSerializer:[AFXMLParserResponseSerializer new]];

[manager GET:url parameters:nil success:^(AFHTTPRequestOperation *operation, NSData *responseObject) {
NSLog(@"DATA: %@", responseObject);
[self stopProgress];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
self.textView.text = error.description;
[self stopProgress];
}];

错误:

Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: application/osm3s+xml" UserInfo=0x1702e1e80 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x17403d080> { URL: http://api.openstreetmap.fr/xapi?node%5Bname=London%5D } { status code: 200, headers { 
Connection = "Keep-Alive";
"Content-Encoding" = gzip;
"Content-Length" = 7166;
"Content-Type" = "application/osm3s+xml";
Date = "Sun, 25 Jan 2015 21:18:54 GMT";
"Keep-Alive" = "timeout=5, max=100";
Server = "Apache/2.2.22 (Debian)";
Vary = "Accept-Encoding";
} }, NSErrorFailingURLKey=http://api.openstreetmap.fr/xapi?node%5Bname=London%5D, com.alamofire.serialization.response.error.data=<3c3f786d 6c207665 7273696f 6e3d2231 2e302220 656e636f 64696e67 (... a lot of numbers ... )>, NSLocalizedDescription=Request failed: unacceptable content-type: application/osm3s+xml}

最佳答案

您的代码:

manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/osm3s+xml"];

非常清楚地创建了 OpenStreetMap 拒绝的 header 。不要设置该 header :将其设置为 value like text/xml ,它被记录为正确的值。

关于ios - 请求失败 : unacceptable content-type: application/osm3s+xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28141732/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com