将 cURL 转换为 Python 请求 [英] Converting cURL to Python Requests
本文介绍了将 cURL 转换为 Python 请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将以下 cURL 命令转换为 python 请求.
I need to convert the following cURL command to python requests.
curl 'https://test.com/api/v1/courses/xx/discussion_topics/xx/entries.json' \
-F 'message=<message>' \
-H "Authorization: Bearer <token>"
到目前为止我有 requests.post("https://test.com/api/v1/courses/xx/discussion_topics/xx/entries")
但是如何添加消息和身份验证?
So far I have requests.post("https://test.com/api/v1/courses/xx/discussion_topics/xx/entries")
but how do I add the message and auth?
推荐答案
requests.post("https://test.com/api/v1/courses/xx/discussion_topics/xx/entries.json, data=json.dumps({"message": "<message>"}), headers={"Authorization": "Bearer <token>"})
这篇关于将 cURL 转换为 Python 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文