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

Unexpected token when posting a json object #10

Closed
albertoleal opened this issue Oct 2, 2012 · 3 comments
Closed

Unexpected token when posting a json object #10

albertoleal opened this issue Oct 2, 2012 · 3 comments

Comments

@albertoleal
Copy link

When I try to send a json object I get
Unexpected token {

Basically, that's what I am sending:
.post(URL+'user/selfRegistration', { {name: "Alberto"} })

When I remove the json object, I get another error:
.post(URL+'user/selfRegistration', {name: "Alberto" })

Error: A JSONObject text must begin with '{' at character 1

Is it a valid scenario?

@chrisjenx
Copy link

.post(c.URL_BASE +'login', {
        email : 'email@address.tld',
        password : 'password'
    } )

Would be valid.

This will get Stringified into the body.

@vlucas
Copy link
Owner

vlucas commented Oct 3, 2012

By default Frisby uses a application/x-www-form-urlencoded Content-Type. If you want Frisby to send the actual JSON in the POST body, simply specify a third parameter (options) with {json: true}.

.post(URL+'user/selfRegistration', { name: "Alberto" }, { json: true })

@vlucas vlucas closed this as completed Oct 3, 2012
@albertoleal
Copy link
Author

It solved my problem.
Thanks a lot! =D

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