POST request using CURL for Rails App POST request using CURL for Rails App curl curl

POST request using CURL for Rails App


With respect to the conversation above, let me write an answer.

If you see a form in rails, it will have a line as mentioned below

<input name="authenticity_token" type="hidden" value="+wFCV3kv0X/WI0qb54BgYlDzi+Tp+6HIGM61a4O6gg0=">

Now, if in ApplicationController you have this line protect_from_forgery then it would always expect authenticity_token and if its not available, it will throw the error thats mentioned in your logs hence I suggested to remove that line because you won't be passing an authenticity_token as a param from you api POST requests.

The reason why your get request is working just fine is because rails doesn't expect authenticity_token on a GET request.

Now, you said you removed protect_from_forgery but you got an internal server error, well that has to be handled by you as it has got nothing to do with GET or POST request but it is an error in your rails application. So solve that error and it should work just fine. Or also post the error log here so may be I can help you with that.

EDIT: Solution to your internal server 500 error

With the logs pasted below, it is also necessary that you allow the attributes in your controller, just as @abhinay mentioned in the code.

Hope that helps