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
| Value | Description |
|---|---|
query_string | Parameters from URL query string |
query | Same as query_string |
body_json | Parameters from JSON request body |
body | Same as body_json |
Default Behavior
When not specified:
GETandDELETEmethods 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_stringbut receives JSON body → 404 - Endpoint configured for
body_jsonbut receives query parameters → 404
Related
- NpgsqlRest Options configuration - Configure default parameter handling
- Comment Annotations Guide - How annotations work
- Configuration Guide - How configuration works
Related Annotations
- HTTP - Define endpoint method
- BODY_PARAMETER_NAME - Specify body parameter
- QUERY_STRING_NULL_HANDLING - NULL handling