Skip to content

REQUEST_PARAM_TYPE

Control how parameters are transmitted to the endpoint - via query string or request body.

Keywords

request_param_type, param_type

Syntax

request_param_type <type>
param_type <type>

type: query_string, query, body, body_json

Values

ValueDescription
query_stringParameters from URL query string
querySame as query_string
body_jsonParameters from JSON request body
bodySame as body_json

Default Behavior

When not specified:

  • GET and DELETE methods use query string
  • All other methods use JSON body

Examples

Force Query String Parameters

sql
create function search_users(_name text, _active bool)
returns setof users
language sql
as $$select * from users where name ilike '%' || _name || '%' and active = _active$$;

comment on function search_users(text, bool) is
'HTTP GET
request_param_type query_string';

Request: GET /api/search-users?_name=john&_active=true

Force JSON Body Parameters

sql
create function get_filtered_data(_filters text)
returns json
language sql
as $$...$$;

comment on function get_filtered_data(text) is
'HTTP GET
request_param_type body_json';

Request:

http
GET /api/get-filtered-data
Content-Type: application/json

{"_filters": "status=active"}

Short Form Keywords

sql
-- Using 'param_type' instead of 'request_param_type'
comment on function func1(text) is
'HTTP
param_type query';

-- Using 'BODY' (case-insensitive)
comment on function func2(text) is
'HTTP
param_type BODY';

POST with Query String

Override the default body behavior for POST:

sql
create function quick_action(_id int)
returns text
language sql
as $$...$$;

comment on function quick_action(int) is
'HTTP POST
param_type query_string';

Request: POST /api/quick-action?_id=123

Behavior

When parameter type doesn't match the request format, the endpoint returns 404 Not Found:

  • Endpoint configured for query_string but receives JSON body → 404
  • Endpoint configured for body_json but receives query parameters → 404

Released under the MIT License.