Sunday 18 August 2019

HTTPie: read json payload from a file

Using redirect '<' operator, you can read the input from a file.

Syntax
http {url} < file.json

guest.json
{
    "firstName" : "Bikash",
    "lastName" :"Prakash"
}

Example

$http POST http://localhost:8080/public/v1/guests/ < guest.json
HTTP/1.1 201 
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Type: application/json;charset=UTF-8
Date: Fri, 02 Aug 2019 11:56:31 GMT
Expires: 0
Pragma: no-cache
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block

{
    "firstName": "Bikash",
    "id": 1,
    "lastName": "Prakash"
}


Previous                                                    Next                                                    Home

No comments:

Post a Comment