Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct usage od SDK #102

Open
mpycio opened this issue Feb 16, 2016 · 3 comments
Open

Correct usage od SDK #102

mpycio opened this issue Feb 16, 2016 · 3 comments

Comments

@mpycio
Copy link

mpycio commented Feb 16, 2016

Hi,
Following example for ios, I have following code:

    let adapter = LBRESTAdapter(URL: NSURL(string: "http://polis.dev:3000/api/v1/"), allowsInvalidSSLCertificate: true)
    let repository = adapter.repositoryWithClass(PolisUserRepository.classForCoder())
    let user = repository.modelWithDictionary([
        "email": "[email protected]",
        "password": "password"
        ]) as! PolisUser;

    user.saveWithSuccess({ () -> Void in
        NSLog("user saved")
        }) { (error:NSError!) -> Void in
            NSLog("")
    }

saveWithSuccess always results in 404, because URL is constructed with 'prototype' path:
URL: http://polis.dev:3000/api/v1/polisUser/prototype/create?...

What am I doing wrong, API explorer doesn't append 'prototype' in request URL

@hideya
Copy link
Contributor

hideya commented Feb 17, 2016

It is weird... It looks like you created a model named PolisUser. Have you write any custom SLRESTContract for that class? (or its super classes?)

BTW, this would not be related, but, is there any particular reason for saying PolisUserRepository.classForCoder() instead of just PolisUserRepository when creating the repository?

@mpycio
Copy link
Author

mpycio commented Feb 17, 2016

I'm using LBx set of classes not SLx and trying to follow this guide: https://docs.strongloop.com/display/public/LB/iOS+SDK. So my PolisUser extends LBPersistedModel, I may be doing it all wrong ;).

@hideya
Copy link
Contributor

hideya commented Feb 18, 2016

@mpycio I see. So, your PolisUser class is a regular LBPersistedModel and it doesn't involve any custom SLRESTContract. Hmm... Could you try this and see if it works? https://github.com/hideya/loopback-swift-simple-example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants