The skills to learn this article come from the old boy openstack teacher Lin Haifeng's tutorial "Lecture 25 Openstack API": https://www.bilibili.com/video/BV1LJ411Y7og?p=25 and https://www.qstack.com .cn/archives/168.html
Among the skills I learned include:
(1) API usage of openstack official documents
(2) Without the help of official documents, directly use the wireshark packet capture tool to grab the required method of constructing url and use it directly.
(1) -H specifies the head, which is to specify the required parameters of the http header. (For example, the X-Auth-Token: and Content-Type: in the header of the tracking flow-http flow we grabbed can be specified with -H)
curl -H "X-Auth-Token:gAAAAABaMImzumUV648tH56PGK38DlE9Jz0G2qg0pv5M7XlrZu1XoXMacvOsJXHH9NgvovrfgeJR-DlFPRrE0wpqdHW9VkSLWwuGZtaKkcX7zRlehrHttLPTigz9UPdQi4GrZ7u2APIG6kIsyKLiVLkUMMDen02FWKQGKZT8eOG2gx-OKDAV1cE" -H "Content-Type: application/json" http://10.0.0.11:9292/v2/images
curl -H "X-Auth-Token:$token" -H "Content-Type: application/json" http://10.0.0.11:9292/v2/images
(2) -X specifies POST GET DELETE and other methods, of course, the default is not to write -X is to specify GET, if it is POST DELETE and other methods, it must be displayed with -X POST or -X DELETE, etc.
(3) You can specify the data with -d. Usually with json string. for example
curl -i -X POST -H "Content-type: application/json" -d'Fill the json string in the quotes (the captured tracking stream-http stream contains the json string data, just post it and modify it slightly)' http://10.0.0.11:5000/v3/auth/tokens
curl -i -X POST -H "Content-type: application/json" \ { "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "domain": { "name": "default" }, "name": "admin", "password": "ADMIN_PASS" } } }, "scope": { "project": { "domain": { "name": "default" }, "name": "admin" } } } }-d '' http://10.0.0.11:5000/v3/auth/tokens
PS that you must you get a stream of wireshark below, you must be
If you get the package 1/2/3/4/5/6/7 above, you have to learn to use curl to construct the corresponding request
1 description is post
2 is the second half of the url, namely /v2.1/c26a0…………17c/servers
3 Prove that the front of the URL is http, that is, http
4Describe the host and port of the middle part of the url, that is, controller:8774
5说明-H "Content-Type: application/json"
6 Description-H "X-Auth-Token:$gAAAA…………"
7 Description of the json data
curl -X 1 -H 5 -H 6 -d '7' 3://4/2
which is
curl -X 1 -H 5 -H 6 -d '7' http://controller:8774/v2.1/c26a0…………17c/servers
PS2: In the later stages of weibo, weixin, and douyin api programming, you can try to capture packets like this! learn by analogy! ! !