Skip to main content

Error 400 when sending URL (cURL)

Error 400 when sending a filtered URL via curl

Written by Petr Pech

The filter in the address contains characters that don't have their usual meaning in a URL — typically >, <, a space, or &. If you don't encode them, the request will fail.


How it shows up

What's in the address

What you get

Invalid escape sequence (e.g., a lone %)

400 Bad Request — the request is rejected by the proxy before it even reaches the core.

Broken filter (e.g., a missing parenthesis)

400 and Špatný formát WQL dotazu, problém na pozici … in the response.

An unencoded character that breaks the filter in a different way (e.g., >)

200, but instead of XML you get an HTML "Operation cannot be performed" page. A program expecting XML will then fail with a parser error.

A space or < in the address

In most cases, the client itself rejects the request and never sends it at all.


How to encode the filter

The most commonly needed characters:

Character

In the address

space

%20

>

%3E

<

%3C

&

%26

%

%25

+

%2B

A correctly encoded command then looks like this:

curl -u uzivatel:heslo -k -L -f \
"https://server:5434/c/{firma}/faktura-vydana/(datSplat%3Enow()).xml" \
-o ds.xml

💡 You can skip manual encoding — most libraries have a ready-made function for it (in Python urllib.parse.quote, in PHP rawurlencode, in JavaScript encodeURIComponent). A filter typed unencoded into a browser's address bar also gets encoded automatically, so you can just copy it back into the clipboard.

⚠️ Enclose the address in quotation marks. Without them, characters like &, (, and ) will be interpreted by the shell in its own way, and something other than what you wrote will be sent.


Related

Did this answer your question?