Skip to main content

Command Palette

Search for a command to run...

Gotcha: Request spec

Updated
1 min read

You may have faced this issue where { key: false } was treated as { “key”: “false” } when writing request specs in rails application development.

Request params need to be passed as json along with content-type header in order for the Rails API to cast the types properly. The to_json converts the ruby hash to a json string and then the headers help Rails parse the request body.

put '/api/v1/crm/update_sync_settings', 
    params: request_param.to_json, 
    headers: {'Content-Type' => 'application/json'}