代码生成器
路径:接口菜单–》生成代码
生成代码界面如下图:
包含的开发语言有:
- cURL
- Java
- PHP
- Go
- Python
- Node
- R
- Rust
- Strest
- Dart
- MATLAB
- Elixir
- Ansible
- Browser
- JsonString
- C#
举几个例子:
C#
// Generated by ApiPost: https://www.apipost.cn/
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
// Generated by ApiPost: https://www.apipost.cn/
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)
最后这张图凑个数哈!
============================开发如流水般丝滑!!!
产品推荐
推荐理由
postman在国内使用已经越来越困难:
1、登录问题严重
2、Mock功能服务基本没法使用
3、版本更新功能已很匮乏
4、某些外力因素导致postman以后能否使用风险较大
出于以上考虑因此笔者自己开发了一款api调试开发工具SmartApi,满足基本日常开发调试api需求
官网地址SmartApi
http://www.smartapi.site/
是的,兄弟们,我还是建立了自己的官网!需要下载的大佬直接去官网下载就可以了蛤,顺便看看官网介绍
看下面的简单的