我使用了0.7.0的Grape gem,并在端点周围有以下验证规则:
params do
requires :UUID, type: String
requires :PrimaryJobFunctionCode, type: String
requires :PrimaryAssetClassCode, type: String
requires :PrimaryGeographicalFocusCode, type: String
requires :SecondaryJobFunctionCodes, type: Array
requires :SecondaryAssetClassCodes, type: Array
requires :SecondaryGeographicalFocusCodes, type: Array
end
post "save" do
我尝试POST的有效负载是:
" { " UUID":" SL1-4E6Z6DW&#34 ;, " PrimaryJobFunctionCode":" FRUCJF:30&#34 ;, " PrimaryAssetClassCode":" FRUCAC:34&#34 ;, " PrimaryGeographicalFocusCode":" G:31&#34 ;, " SecondaryJobFunctionCodes":[" FRUCJF:69&#34], " SecondaryAssetClassCodes":[" FRUCAC:24&#34], " SecondaryGeographicalFocusCodes":[" G:3D"]}"
我得到的错误是:
"UUID is missing, PrimaryJobFunctionCode is missing, PrimaryAssetClassCode is missing, PrimaryGeographicalFocusCode is missing, SecondaryJobFunctionCodes is missing, SecondaryAssetClassCodes is missing, SecondaryGeographicalFocusCodes is missing"
我一定错过了一些明显的东西