python - API测试: Postman vs Python Requests

标签 python xml api python-requests postman

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

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

关于python - API测试: Postman vs Python Requests,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49680816/

相关文章:

python - 将格式化的时间字符串转换为毫秒

python - 背景减法器

ruby - 回形针远程 URL

javascript - CakePhp:使用 CakePHP HttpClient 调用 API 时,响应正文中出现错误

api - 是否可以通过 LinkedIn API 接收职位申请?

Python组合图在条形图上添加百分比但错误

python - 将从文件读取的 True/False 值转换为 boolean 值

java - 显示 AVD 的日志

python - 在 Python 中解析 XML 字符串片段流

python - 在Python中,检索Xml属性值