cURL Works, but the Converted Python or Fetch Code Doesn’t. What Changed?
The cURL command works in your terminal, but the fetch code generated from it won’t read the response. Which parts of a request change once another runtime sends it?

- curlconverter turns HTTP requests into Python, JavaScript and other languages.
- Body encoding, redirects and browser CORS rules can change the result after conversion.
- Generating code does not execute the request or establish that the new runtime behaves identically.
A translated request can inherit different defaults
When converted code fails, compare the body and runtime as well as the URL. The curlconverter README explicitly documents differences such as redirect defaults. Its scope is HTTP, and recognizing an option does not mean reproducing every behavior attached to it.
In Chrome DevTools Network, right-click the request and choose Copy → Copy as cURL. Paste it into curlconverter and select the Python or JavaScript output. The project says conversion runs in the browser without transmitting or recording the input command or generated code.
Copied requests can contain cookies and authorization credentials. Remove their values before posting a debugging example publicly. When moving into application code, decide which identity the new request should use; a separate Python process does not automatically inherit the browser’s signed-in session.
JSON, form data and query parameters are different inputs
Requests distinguishes three common cases:
| Original input | Python argument |
|---|---|
| URL query string | params |
| JSON body | json |
| Form-encoded fields | A dictionary passed as data |
This illustrative JSON request uses a placeholder endpoint, not a tested service:
import requests
response = requests.post(
"https://api.example.com/items",
json={"quantity": 2},
timeout=10,
)
response.raise_for_status() A pre-serialized string passed as data needs the intended Content-Type header. Do not also pass data alongside json: Requests ignores json in that case. The timeout shown is not a ten-second deadline for the entire operation.
Web-page fetch has an additional CORS boundary
For a cross-origin browser request, the server must allow the page to read the response. MDN explains that non-simple requests also require a successful preflight before the actual request is sent.
Adding mode: "no-cors" does not make a JSON API readable. The resulting opaque response hides its body and headers from JavaScript. Browsers also prevent scripts from setting certain request headers, so copying every cURL header into a fetch call is insufficient.
If only the browser version fails, inspect the page’s origin and the server’s CORS response. A successful Python request answers a different question from whether a web page may read that response.
Make redirect and file behavior explicit
curl does not follow HTTP redirects by default; -L enables that behavior. Requests follows them for its usual request methods. Use allow_redirects=False when the initial response matters. curlconverter warns that leaving policy unspecified can preserve this difference between runtimes.
Likewise, --data @filename produces code that reads a file, rather than embedding its contents. The file must exist at the right path on the machine running the generated code. More complex shell syntax can exceed the converter’s capabilities.
A useful review order is to match method, full URL and body first, then check browser permissions or runtime defaults. The generated snippet gets the request into your language; its actual request and response establish whether the move preserved the behavior you needed.