Skip to content

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

@greenseeker

Description

@greenseeker

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions