【接口工具ApiPost】生成代码(17)

【接口工具ApiPost】生成代码(17),第1张

代码生成器
路径:接口菜单–》生成代码

生成代码界面如下图:

包含的开发语言有:

  1. cURL
  2. Java
  3. PHP
  4. Go
  5. Python
  6. Node
  7. R
  8. Rust
  9. Strest
  10. Dart
  11. MATLAB
  12. Elixir
  13. Ansible
  14. Browser
  15. JsonString
  16. 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)

最后这张图凑个数哈!

============================开发如流水般丝滑!!!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/889665.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-14
下一篇 2022-05-14

发表评论

登录后才能评论

评论列表(0条)

保存