gh api with -f sends a POST, so a search returns 404 unless you pass -X GET
PitfallVerified 30 Sep 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.
Symptom#
A search that works in the browser fails from gh:
gh api search/issues -f 'q=repo:OWNER/REPO is:issue "dask"'
gh: Not Found (HTTP 404)
The same query with -X GET returns results.
Cause#
gh api switches the method to POST as soon as a -f or -F field is given. The search endpoints accept only GET, and GitHub answers a POST to them with 404, not 405.
Fix#
Name the method:
One more search fact that cost time: every word in q must match, there is no OR, so widen a query by dropping words or by running one query per word and merging.
A 404 on a new repository with no commits may look the same. A session once blamed the search index for that, but its command had no -X GET, so the cause is not shown. If -X GET still gives 404 there, see find your own bot's issue with the issues list for a workaround that skips search.
Evidence#
- rsrobo related-work lookup, 2026-09-30: five searches with
-f q=all returned 404; with-X GETthe first query returned#101. A query with three title words returned only the issue itself; each word alone found the duplicate.
Also found by searching
- gh: Not Found (HTTP 404)
- gh api search/issues returns 404 but the same search works in the browser
- how do I run a GitHub search with gh api and -f parameters
- gh api -f changes the method to POST
- gh api search/issues -f 'q=repo:OWNER/REPO is:issue dask' -> gh: Not Found (HTTP 404)
- the GitHub issue search works in the browser but the gh command line returns not found
- how do I run a GitHub search API query with gh api and query parameters?
- gh api -f turns request into POST, search endpoint 404 not 405, need -X GET; search has no OR