Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http-prompt producing different 'data' than httpie #203

Open
greenseeker opened this issue Aug 19, 2021 · 0 comments
Open

http-prompt producing different 'data' than httpie #203

greenseeker opened this issue Aug 19, 2021 · 0 comments

Comments

@greenseeker
Copy link

When I use httpie, you can see data is a byte-literal string:

# printf '{"username": "admin", "password": "YWRtaW4=", "timeout": 60}' | http POST http://localhost/api/Login Accept:'application/json' Content-Type:'application/json' --debug
...
>>> requests.request(**{'auth': None,
 'data': b'{"username": "admin", "password": "YWRtaW4=", "timeout": 60}',
 'headers': {'User-Agent': b'HTTPie/2.4.0', 'Accept': b'application/json', 'Content-Type': b'application/json'},
 'method': 'post',
 'params': <generator object MultiValueOrderedDict.items at 0x7f7c8bdfde08>,
 'url': 'http://localhost/api/Login'})

The above successfully authenticates. When I do the equivalent (as best I can tell) in http-prompt, however:

# http-prompt localhost --debug
Version: 2.1.0
http://localhost> cd api/Login
http://localhost/api/Login> Accept:application/json
http://localhost/api/Login> Content-Type:application/json
http://localhost/api/Login> username='admin'
http://localhost/api/Login> password='YWRtaW4='
http://localhost/api/Login> timeout=60
http://localhost/api/Login> post
...
>>> requests.request(**{'auth': None,
 'data': '{"password": "YWRtaW4=", "timeout": "60", "username": "admin"}',
 'headers': {'User-Agent': b'HTTPie/2.4.0', 'Accept': b'application/json', 'Content-Type': b'application/json'},
 'method': 'post',
 'params': <generator object MultiValueOrderedDict.items at 0x7f554bb2e678>,
 'url': 'http://localhost/api/Login'})

Here the 'b' is missing at the start of the data value and I get "Request body is empty or format is invalid." Is this something I can control or is it a limitation of http-prompt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant