Plain Text API Body

Please add the option to send API body in and format we want. I need a big text box to send API body exactly as I type it. My only option currently is key pairs but this sends in a format not all endpoints accept.

Currently we’re locked into how Bricksforge wants to send it, but this isn’t always how the endpoint wants it.

For example, via Bricks Query Loop API the body is sent like this:

fields name,total_rating,summary,storyline,first_release_date;
where id = 23248;

If I attempt to do the same thing with BricksForge API, I get this:

{"fields":"name,total_rating,summary,storyline,first_release_date; ","where id =":"23248;"}

Which the endpoint I’m sending to, just doesn’t understand.

Hi, and thanks for the detailed write-up.

You are right about the current behaviour. In the API Query Builder, the request body for a POST is built exclusively from the Key/Value repeater, and the Body Type dropdown only offers JSON (application/json) and Form Data (x-www-form-urlencoded). There is currently no “raw / plain text” body option, so a query like the IGDB / APICalypse syntax you posted…

fields name,total_rating,summary,storyline,first_release_date;
where id = 23248;

…can’t be expressed through key/value pairs, which is exactly why it ends up as that broken JSON object.

I have logged this as a feature request to add a raw text body option (a free text box plus a Content-Type you can set yourself, e.g. text/plain). Thanks for pushing for it.

In the meantime there is a working PHP workaround. The builder exposes a filter right before the request is sent, so you can replace the body and the Content-Type yourself:

add_filter('bricksforge/api_query_builder/request_args', function ($request_args, $item) {
    // Only target the relevant API item (check $item->url or $item->id)
    if (strpos($item->url ?? '', 'igdb.com') !== false) {
        $request_args['body'] = "fields name,total_rating,summary,storyline,first_release_date; where id = 23248;";
        $request_args['headers']['Content-Type'] = 'text/plain';
    }
    return $request_args;
}, 10, 2);

That sends the body exactly as typed, with full control over the Content-Type header. (You can also use bricksforge/api_query_builder/request_headers if you only need to adjust headers.)

Let me know if that unblocks you for now.

Best,
Daniele