logesh
logesh

Reputation: 2672

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":[email protected], "password":qwerty, "password_confirmation":qwerty}}"

but i receive an error as

MultiJson::DecodeError (795: unexpected token at '{user : {Email:[email protected], password:qwerty, password_confirmation:qwerty}}')

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

Upvotes: 4

Views: 2191

Answers (1)

maximus ツ
maximus ツ

Reputation: 8065

try this one,

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

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

Upvotes: 1

Related Questions