[英]How to write RESTful web services client based on curl
I need to write a RESTful web service client for Delphix.I am new to delphix and RESTful webservices.How can I write a client based on the below curl. 我需要为Delphix编写一个RESTful Web服务客户端。我是Delphix和RESTful Webservices的新手,如何基于下面的curl编写客户端。
Create Delphix API Session 创建Delphix API会话
$ curl -s -X POST -k --data @- http://delphix-server/resources/json/delphix/session \\ -c ~/cookies.txt -H "Content-Type: application/json" <
$ curl -s -X POST -k --data @ -http:// delphix-server / resources / json / delphix / session \\ -c〜/ cookies.txt -H“内容类型:application / json” <
Delphix Login
$ curl -s -X POST -k --data @- http://delphix-server/resources/json/delphix/login \\ $ curl -s -X POST -k --data @ -http:// delphix-server / resources / json / delphix / login \\
-b ~/cookies.txt -H "Content-Type: application/json" <<EOF { "type": "LoginRequest", "username": "delphix_username", "password": "delphix_password" } EOF
please help 请帮忙
Just use decomposition for curl commands. 只需对curl命令使用分解。 For example as we see Authentication requres two steps:
例如,如我们所见, 身份验证需要两个步骤:
1. create session: 1.创建会话:
POST request to http://delphix-server/resources/json/delphix/session
with JSON-data: 通过JSON数据向
http://delphix-server/resources/json/delphix/session
发出POST请求:
{
"type": "APISession",
"version": {
"type": "APIVersion",
"major": 1,
"minor": 1,
"micro": 0
}
}
where you specify API version 您指定API版本的位置
2. login operation: 2.登录操作:
POST request to http://delphix-server/resources/json/delphix/login
with JSON data: 通过JSON数据向
http://delphix-server/resources/json/delphix/login
发出POST请求:
{
"type": "LoginRequest",
"username": "delphix_username",
"password": "delphix_password"
}
also your client must support cookies (for store auth session) 您的客户也必须支持Cookie(用于商店身份验证会话)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.