这是我的API post
:
resource :service_requests do
get do
authenticate!
current_company.service_requests
end
params do
requires :service_request, type: Hash do
optional :prefix, type: String
requires :first_name, type: String
requires :last_name, type: String
requires :contact_email, type: String, regexp: User::EMAIL_REGEX
requires :telephone, type: String
end
end
post do
authenticate!
{ service_request: params[:service_request] }
end
end
这是我的json
帖子:
{
'service_request': {
'first_name': 'Foo',
'last_name': 'Bar',
'contact_email': '[email protected]',
'telephone': '111-111-1111'
}
}
我收到的错误是:
ActionDispatch::ParamsParser::ParseError (795: unexpected token at '{
'service_request': {
'first_name': 'Foo',
'last_name': 'Bar',
'contact_email': '[email protected]',
'telephone': '111-111-1111'
}
}'):
不知道我在做什么错。有人看到什么很突出吗?
在json中使用双引号:
{
"service_request": {
"first_name": "Foo",
"last_name": "Bar",
"contact_email": "[email protected]",
"telephone": "111-111-1111"
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句