I am building an api and my route for POST (create) is /api/v1/studios
The controller
def create
@studio = Studio.new(studio_params)
if @studio.save
render json: @studio, status: :created, location: @studio
else
render json: @studio.errors, status: :unprocessable_entity
end
end
private
def studio_params
params.permit(:name)
end
When i try to create an instance through curl ->
curl -X POST -v http://localhost:3000/api/v1/studios -H "Content-Type: application/json" -d '{"name":"studio1"}'
All i get is this errori wrote on the title.
Parsing error, could not resolve host: studio1}'
and in the development.log i get:
ActionDispatch::Http::Parameters::ParseError (783: unexpected token at ''{name:Disney}''):
Error occurred while parsing request parameters. Contents:
'{name:Disney}'
If that curl
command is what you're running, then there's likely an issue with how your shell is processing the various quotes. That's in bash
format, so if your shell doesn't adhere to that standard you'll get inexplicable syntax errors.