python

httpie post request example

pyman 2019. 11. 8. 09:17
]# http -v POST https://openstack/loadbalancers/ \
extra_rules:='[{
    "listener": {"protocol": "HTTP", "protocol_port": 80, "x_forwarded_for": true, "x_forwarded_port": true, "x_forwarded_proto": true},
    "member": {"protocol_port": 80},
    "monitor": {"delay": 5, "max_retries": 3, "timeout": 3, "type": "HTTP", "url_path": "/"},
    "pool": {"lb_algorithm": "ROUND_ROBIN", "protocol": "HTTP"}
}]' \
extra_security_groups:='[]' \
name=l2 project=fea99e8d-05a9-4f30-95c5-1fdab936ece9

POST /v1/loadbalancers/ HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 430
Content-Type: application/json
Host: openstack
User-Agent: HTTPie/0.9.9

{
    "extra_rules": [
        {
            "listener": {
                "protocol": "HTTP",
                "protocol_port": 80,
                "x_forwarded_for": true,
                "x_forwarded_port": true,
                "x_forwarded_proto": true
            },
            "member": {
                "protocol_port": 80
            },
            "monitor": {
                "delay": 5,
                "max_retries": 3,
                "timeout": 3,
                "type": "HTTP",
                "url_path": "/"
            },
            "pool": {
                "lb_algorithm": "ROUND_ROBIN",
                "protocol": "HTTP"
            }
        }
    ],
    "extra_security_groups": [],
    "name": "l2",
    "project": "fea99e8d-05a9-4f30-95c5-1fdab936ece9"
}

HTTP/1.1 201 Created
Allow: GET, POST
Connection: keep-alive
Content-Length: 584
Content-Type: application/json
Date: Fri, 08 Nov 2019 00:14:50 GMT
Server: nginx
Vary: Accept
X-Frame-Options: SAMEORIGIN

{}