httpie / cli

🥧 HTTPie CLI — modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more.
https://httpie.io
BSD 3-Clause "New" or "Revised" License
32.7k stars 3.67k forks source link

How to post an empty string as a data field? #1528

Closed maxclac closed 10 months ago

maxclac commented 10 months ago

Hi!

How is it possible to post an empty string as a data field like:

http PUT pie.dev/put  name= 

Do I need to escape the empty string somehow?

jkbrzt commented 10 months ago

You don’t need to escape it.


JSON:

$ http -v pie.dev/post name=
POST /post HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 12
Content-Type: application/json
Host: pie.dev
User-Agent: HTTPie/3.2.2

{
    "name": ""
}

Form:

$ http -v --form  pie.dev/post name=
POST /post HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 5
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Host: pie.dev
User-Agent: HTTPie/3.2.2

name=
maxclac commented 10 months ago

OK, that's strange. It must be the application that does not understand somehow this empty field and probably not an Httpie problem.