一、从charles等抓包工具中请求地址复制为CURL粘贴至postman可直接生成接口请求
操作:1、如下图右键->复制cURL Request
复制后代码示例:
curl -H 'Host: www.baidu.com' -H 'user-agent: Android Phone 22 com.hfjy.learningparentphone 2.0.5' -H 'uuid: 234795ca-ee25-5a2a-6384-1492fefaff6d' -H 'x-hf-learn-session-id: 5puvyxjzs8m87n7b7k34' -H 'content-type: application/x-www-form-urlencoded' --data-binary "version=68&platformType=2" //请求格式
--compressed 'https://www.baidu.com'
2、导入postman
二、从chrome等浏览器中请求地址复制为CURL粘贴至postman可直接生成接口请求
复制后代码示例:
curl 'https://recomm.cnblogs.com/api/v2/recomm/blogpost/reco'
-H 'Accept: application/json, text/javascript, */*; q=0.01'
-H 'Referer: https://www.cnblogs.com/'
-H 'Origin: https://www.cnblogs.com' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36'
-H 'Content-Type: application/json; charset=UTF-8'
--data-binary '{"itemId":10920841,"itemTitle":"Charles mock数据方法"}' --compressed
导入postman方法参照charles
三、详细cURL规则
curl的一般格式curl <一个url>
- 用curl -X POST 请求地址 指定request请求方式
- 用-H 'key=value'指定header键值对
- 用--data-binary '{"key":"value"}' ——application/json
- 用--data-binary ”version=68&platformType=2“——application/Text
- 用-d ”version=68&platformType=2“——application/x-www-form-urlencoded