Strongloop iOS User Creation Error

不羁的心 提交于 2019-12-12 04:47:27

问题


I'm trying to create and save a test user in server with this code:

LBRESTAdapter *adapter = ((AppDelegate *)[[UIApplication sharedApplication] delegate]).adapter;
    if (adapter) {
            TeacherRepository *repo = (TeacherRepository *)[adapter repositoryWithClass:[TeacherRepository class]];
            if (repo) {
                Teacher *st = (Teacher *)[repo createUserWithEmail:@"test@test.com" password:@"test"];
                if (st) {
                    [st saveWithSuccess:^{
                        NSLog(@"Saved in server!");
                    } failure:^(NSError *error) {
                        NSLog(@"Error: %@", error.description);
                    }];
                }
            }
       }

but I keep on getting this error response:

Error Domain=AFNetworkingErrorDomain Code=-1011 "Expected status code in (200-299), got 404"

I have searched for this error and similar others, but couldn't find anything that would solve my problem, so what could be causing this?


回答1:


The HTTP Status Code of 404 means that the resource was not found:

404 Not Found

The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable.

It would appear that there is an error in the building of the URL in your AFNetworking code. You haven't shared that portion of code, so it's hard to comment on the specifics. I think if you log the entire error object (not just error.description) it will show you what URL it attempted to use unsuccessfully.



来源:https://stackoverflow.com/questions/26351811/strongloop-ios-user-creation-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!