Sunday 18 August 2019

How to make a post with empty json payload through HTTPie?


Use <<< operator like below.

Syntax
http POST {URL} Content-Type:application/json <<< '{}'

Example
http -v POST http://localhost:8080/public/aboutUs Content-Type:application/json <<< '{}'

$http -v POST http://localhost:8080/public/aboutUs Content-Type:application/json <<< '{}'
POST /public/aboutUs HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 3
Content-Type: application/json
Host: localhost:8080
User-Agent: HTTPie/1.0.2

{}

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 15:13:30 GMT
Expires: 0
Pragma: no-cache
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block

{
    "address": null,
    "establishedYear": 0,
    "name": null
}



Previous                                                    Next                                                    Home

No comments:

Post a Comment