404找不到有效网址的错误

时间:2016-11-02 06:23:21

标签: ios objective-c web-services afnetworking

使用afnetworking,找不到404有效网址。同样的网址在帖子中工作得很好。

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 Console和Post man截图。 Xcode Console

邮差回应

Postman

1 个答案:

答案 0 :(得分:2)

如果您使用curl标记-i,则会发现您的网址存在问题:

$ 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