简体   繁体   中英

How can i post a json data to rails app?

I want to send the user information for sign up and the following is the request

curl -H 'Content-Type: application/json' -H 'Accept: application/json' -X POST http://localhost:3000/users.json -d "{"user" : {"Email":sample@example.com, "password":qwerty, "password_confirmation":qwerty}}"

but i receive an error as

MultiJson::DecodeError (795: unexpected token at '{user : {Email:sample@example.com, password:qwerty, password_confirmation:qwerty}}')

I do not know what wrong i am doing? Please help me.

try this one,

curl -H 'Content-Type: application/json'  -X POST http://localhost:3000/users.json -d "{\"user\":{\"email\":\"sample@example.com\", \"password\":\"qwerty\",\"password_confirmation\":\"qwerty\"}}"

Problem was with the parameters parsing, need to be within quotes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM