OpenBB-finance/OpenBB · error · ValueError
Method must be GET or POST
Error message
Method must be GET or POST
What it means
Raised by openbb_core.provider.utils.helpers.make_request (and its async twin amake_request) when the 'method' argument, after .upper(), is neither 'GET' nor 'POST'. The helper deliberately supports only these two verbs; anything else ('PUT', 'DELETE', lowercase variants are fine) raises ValueError before any HTTP call is made.
Source
Thrown at openbb_platform/core/openbb_core/provider/utils/helpers.py:565
# Allow a custom session for caching, if desired
_session = kwargs.pop("session", get_requests_session(**kwargs))
if method.upper() == "GET":
return _session.get(
url,
headers=headers,
timeout=timeout,
**kwargs,
)
if method.upper() == "POST":
return _session.post(
url,
headers=headers,
timeout=timeout,
**kwargs,
)
raise ValueError("Method must be GET or POST")
def to_snake_case(string: str) -> str:
"""Convert a string to snake case."""
import re # pylint: disable=import-outside-toplevel
s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", string)
return (
re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1)
.lower()
.replace(" ", "_")
.replace("__", "_")
)
async def maybe_coroutine(
func: Callable[P, T | Awaitable[T]], /, *args: P.args, **kwargs: P.kwargs
) -> T:View on GitHub (pinned to 3e071fcc2c)
Solutions
- Restrict the call to method='GET' or method='POST'
- If you truly need other verbs, use the session object directly: get_requests_session().put(url, ...) from openbb_core.provider.utils.helpers
- Validate/whitelist the method at your API boundary before it reaches make_request
Example fix
# before resp = make_request(url, method="DELETE") # ValueError: Method must be GET or POST # after from openbb_core.provider.utils.helpers import get_requests_session resp = get_requests_session().delete(url, timeout=10)
Defensive patterns
Strategy: type-guard
Validate before calling
ALLOWED_METHODS = {"GET", "POST"}
method = method.upper()
if method not in ALLOWED_METHODS:
raise ValueError(f"unsupported method {method}; use one of {sorted(ALLOWED_METHODS)}") Type guard
from typing import Literal
HttpMethod = Literal["GET", "POST"]
def is_supported_method(m: str) -> bool:
return m.upper() in {"GET", "POST"} Try / catch
from openbb_core.provider.utils.helpers import make_request
try:
resp = make_request(url, method=method)
except ValueError as e:
if "Method must be GET or POST" in str(e):
resp = get_requests_session().request(method, url) # escape hatch for other verbs
else:
raise Prevention
- Type method parameters as Literal['GET','POST'] so static checkers catch bad calls
- Whitelist and uppercase the method at your API boundary
- For arbitrary verbs, use the session from get_requests_session() directly instead of make_request
When it happens
Trigger: Calling make_request(url, method='PUT'|'DELETE'|'PATCH'|'HEAD'|'OPTIONS') directly from a custom provider fetcher, or passing an unvalidated user-supplied method string through to it.
Common situations: Custom provider authors porting code from requests.sessions.Session (which supports all verbs) into OpenBB's helper; building a generic proxy that forwards arbitrary HTTP methods.
Related errors
- There was an error with the HTTP request
- Error with the request: {r.status_code}
- Failed to download document from {url}. Status code: {respon
- An error occurred while fetching constraints {dataflow_id}:
- An error occurred during the HTTP request: {url} -> {e} -> {
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/61378d0416f929fb.
Report an issue: GitHub.