代码生成器 路径:接口菜单–》生成代码
生成代码界面如下图:
包含的开发语言有:
- cURL
- Java
- PHP
- Go
- Python
- Node
- R
- Rust
- Strest
- Dart
- MATLAB
- Elixir
- Ansible
- Browser
- JsonString
- C#
举几个例子:
C#
using (var httpClient = new HttpClient())
{
using (var request = new HttpRequestMessage(new HttpMethod("Get"), "https://console-mock.apipost.cn/app/mock/project/e506875e-055f-452a-c781-e00e05f2f9f9/getUserInfo"))
{
request.Headers.TryAddWithoutValidation("User-Agent", "Apipost client Runtime/+https://www.apipost.cn/");
request.Headers.TryAddWithoutValidation("Content-Type", "application/json");
var response = await httpClient.SendAsync(request);
}
}
Java
Request request = Request.Get("https://console-mock.apipost.cn/app/mock/project/e506875e-055f-452a-c781-e00e05f2f9f9/getUserInfo");
String body = "'";
request.bodyString(body,ContentType.APPLICATION_JSON);
request.setHeader("User-Agent", "Apipost client Runtime/+https://www.apipost.cn/");
request.setHeader("Content-Type", "application/json");
HttpResponse httpResponse = request.execute().returnResponse();
System.out.println(httpResponse.getStatusLine());
if (httpResponse.getEntity() != null) {
String html = EntityUtils.toString(httpResponse.getEntity());
System.out.println(html);
}
Python:
import requests
headers = {
'User-Agent': 'Apipost client Runtime/+https://www.apipost.cn/',
'Content-Type': 'application/json',
}
response = requests.post('https://console-mock.apipost.cn/app/mock/project/e506875e-055f-452a-c781-e00e05f2f9f9/getUserInfo', headers=headers)
最后这张图凑个数哈!
============================开发如流水般丝滑!!!
|