ZAX
ZAX

Reputation: 1008

POST/PUT json issues with Rails and PostgreSQL database

I have a heroku application running Rails and a PostgreSQL database.

My understanding is that with my current settings I am capable of posting or putting data to the appropriate pages. I am using mozilla firefox's POSTER add on to help with the testing/process at this point just for validation.

The issue though is, when I make a POST or PUT request to the appropriate page, I get a 422 error and it says unprocessable entity.

Here is the json I am trying to post:

{
    "userID":1,
    "username":"test",
    "phoneCred":1,
    "won":1,
    "lost":1,
    "previousGamePlace":1,
    "leagueID":0,
    "rosterID":0
    };

I believe it to be valid json, and each one of the above fields exists in my database, however when I post to the correct url, I get that 422 error. Does anyone know how to use the this feature of Rails?

the url is of this form: /users.json

Upvotes: 0

Views: 80

Answers (2)

aarti
aarti

Reputation: 2865

There is probably an error, or the record exists. Is there a way for you to check the response, may be use Curl, or debug in a browser dev tools

Upvotes: 0

Paritosh Piplewar
Paritosh Piplewar

Reputation: 8122

it is not valid . rosterID should be quoted.

Upvotes: 1

Related Questions