Hello, I am trying to use the API query builder but I keep on getting Error 500 when fetching.
This simple JS does work, but as I’d like to take advantage of the dynamic tags I tried all sorts of combinations with custom headers etc in the query builder but I always get a 500. Thanks in advance!
[26-Jun-2026 11:25:54 UTC] Bricksforge: API request failed for item id: 5b375956-27b3-6f9a-5579-1293341eb950:
[26-Jun-2026 11:25:54 UTC] PHP Warning: Undefined array key 0 in /www/htdocs/xyz/xyz/wp-includes/rest-api.php on line 3457
Thanks for the detailed report, and especially for digging out the server log — that’s exactly what we needed.
Two things are going on here:
1. The 500 itself is misleading. It’s our side not handling a failed request gracefully: when the underlying HTTP call returns an error instead of a normal response, we end up producing an empty error object, and WordPress core then throws that “Undefined array key 0 in rest-api.php” warning and returns a 500. So the 500 is masking the real problem rather than being it. We’ve noted a fix on our end so the actual error surfaces instead of a generic 500 — that’ll make cases like this much easier to diagnose going forward.
2. The real cause is that the request fails server-side. Notice the log line ends right after the item id with nothing after it — the response body is empty. That’s the key difference from your working snippet: your fetch runs in the browser, but the API Query Builder makes the request from your WordPress server via PHP. A call that works fine from the browser can still fail server-side — common reasons are the host blocking outbound server-to-server requests, an SSL/TLS issue, or the endpoint behaving differently without the headers the browser sends.
Your working snippet sends X-Requested-With: fetch and Content-Type: application/json. Many endpoints (Discourse-style .json URLs especially) only return JSON when X-Requested-With is present — otherwise they redirect to an HTML page, which a server-side request won’t follow the same way. So as a first step: in the Query Builder, add those two headers and fetch again:
X-Requested-With: fetch
Content-Type: application/json
If it still fails after that, then yes — staging credentials would be very helpful. With access I can reproduce the server-side request directly and pin down whether it’s the headers, SSL, or the host blocking the call.