Search code examples
iosnode.jshttpdigital-oceanstrongloop

Strongloop iOS User Creation Error


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:@"[email protected]" 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?


Solution

  • 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.