Skip to main content
 首页 » 编程设计

python之接口(interface)测试 : Postman vs Python Requests

2025年01月19日13jyk

我可以使用 postman 发送邮寄请求。但是我用 python 请求库失败了:

headers = {'Content-Type': 'application/xml'} 
r = requests.post(url, data=xml, headers=headers) 

为什么postman测试没问题? postman和python请求post有什么区别?

请您参考如下方法:

好的 - 只是回答问题,因为@OluwafemiSule 的原始链接现在返回 404。在 Postman 中,在右上角的“发送”下拉菜单正下方是一个标有“代码”的小文本按钮。按下它,您可以选择查看编码为以多种语言运行的传输 - 包括 python/requests。截至 02/2019 的更新链接:https://learning.getpostman.com/docs/postman/sending_api_requests/generate_code_snippets/#___gatsby