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

Unsupported URL error? #8

Closed
Rhuantavan opened this issue Oct 15, 2015 · 3 comments
Closed

Unsupported URL error? #8

Rhuantavan opened this issue Oct 15, 2015 · 3 comments

Comments

@Rhuantavan
Copy link

Over at SO I have posted a question about siesta erroring-out on a simple post request:
http://stackoverflow.com/questions/33147850/siesta-ios-post-request-errors-out-with-unsupported-url

Unfortunately I cannot create a new "siesta-swift" since I haven't got enough reputation to create a new tag.

Siesta configuration & login server call

let api = Service(base: "http://myapidomain.net/rest")

enabledLogCategories = LogCategory.all

let parameters = ["username": "username", "password": "password"]

api.resource(url: "users/login").request(.POST, json: NSDictionary(dictionary: parameters)).success { data in
    debugPrint("success logging in")
}.failure { error in
    debugPrint("failed to log in")
}

Debug log

[Siesta:Configuration] Computing configuration for Siesta.Resource(users/login)[]
[Siesta:Configuration] Applying config 0 [Siesta default response transformers] to Siesta.Resource(users/login)[]
[Siesta:NetworkDetails] Request: 
    headers: (1)
      Content-Type: application/json
[Siesta:Network] POST users/login
[Siesta:Network] – ← POST users/login
[Siesta:NetworkDetails] Raw response headers: –
[Siesta:NetworkDetails] Raw response body: 0 bytes
[Siesta:NetworkDetails] Response after transformer pipeline:  (new data) 
   Failure
     userMessage:    "unsupported URL"
     nsError:        "unsupported URL"
"failed to log in"
@pcantrell
Copy link
Member

That's a good heads up about tagging requiring reputation on Stack Overflow. Hand’t even occurred to me! Perhaps I'll rethink that recommendation about getting help in the README.

The Service.resource(url:) method — the one with the parameter labeled url: — expects a complete URL. It looks like you want Service.resource(_:), which takes a path relative to the Service’s base URL.

Try:

api.resource("users/login")

@Rhuantavan
Copy link
Author

Yes, the resource(url:) was the problem. Thanks.

@pcantrell
Copy link
Member

Sure thing!

On Oct 15, 2015, at 9:50 AM, Rhuantavan notifications@github.com wrote:

Yes, the resource(url:) was the problem. Thanks.


Reply to this email directly or view it on GitHub #8 (comment).

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

2 participants