此示例显示如何在请求中发送 JSON 数据以创建新资源:
$ curl --user ${USER}:${PASSWORD} -s -k -i -X POST -d @- \
-H "Content-Type: application/json" \
https://zfssa-host.example.com:215/api/user/v1/users <<JSON
> {"logname": "rest_user",
> "fullname": "REST User",
> "initial_password": "letmein"}
> JSON
HTTP/1.1 201 Created
Date: Tue, 23 Jul 2013 13:07:37 GMT
Server: WSGIServer/0.1 Python/2.6.4
X-Zfs-Sa-Appliance-Api: 1.0
Content-Type: application/json
Content-Length: 357
{
"user": {
"logname": "rest_user",
"fullname": "REST User",
"initial_password": "DummyPassword",
"require_annotation": false,
"kiosk_mode": false,
"kiosk_screen": "status/dashboard",
"roles": ["basic"],
"exceptions": {},
"preferences": {
"href": "/api/user/v1/users/larry/preferences",
"locale": "C",
"login_screen": "status/dashboard",
"session_timeout": 15,
"advanced_analytics": false,
"keys": {}
}
}
}