【问题标题】:404 not found error for valid url404 未找到有效 url 的错误
【发布时间】:2016-11-02 06:23:20
【问题描述】:

afnetworking 得到 404 未找到有效 url。相同的网址在邮递员中运行良好。

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];
    [manager.requestSerializer setValue:[@"Bearer " stringByAppendingString:[[NSUserDefaults standardUserDefaults]valueForKey:@"authKey"]] forHTTPHeaderField:@"Authorization"];
    [manager POST:[NSString stringWithFormat:@"http://api.fp.com/api/v1/vendor/NotifyConsumerAlbumIsCreated"] parameters:paramsDict success:^(AFHTTPRequestOperation *operation, id responseObject) {
        if(completion)
            completion(responseObject, YES);

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Error is %@",error);
    }];

Xcode 控制台和 Post man 截图回复。

邮递员回复

【问题讨论】:

  • post man 没有显示 excat 错误,在我们的开发中设置了 AFHTTPRequestSerializer 类型
  • 我认为你输入错误的网址不是“http://”而是输入“https://”
  • 我只需要使用http,你可以查看邮递员截图

标签: ios objective-c web-services afnetworking


【解决方案1】:

如果您使用-i 标志执行curl,您会发现您的网址有问题:

$ curl -i -X POST http://api.fp.com/api/v1/vendor/NotifyConsumerAlbumIsCreated
HTTP/1.1 301 Moved Permanently
Date: Wed, 02 Nov 2016 09:58:55 GMT
Location: https://www.friendslife.co.uk/
Content-Length: 0
X-Powered-By: Servlet/2.4 JSP/2.0

【讨论】:

    猜你喜欢
    • 2016-08-28
    • 1970-01-01
    • 2017-12-14
    • 2014-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-20
    相关资源
    最近更新 更多