卷曲转换到Python要求 [英] Converting cURL to Python Requests

查看:125
本文介绍了卷曲转换到Python要求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以下cURL命令转换为蟒蛇的请求。

 卷曲'https://test.com/api/v1/courses/xx/discussion_topics/xx/entries.json'\\
 -F的消息= LT;消息>' \\
 -H授权:承载<令牌GT;

到目前为止,我有 requests.post(https://test.com/api/v1/courses/xx/discussion_topics/xx/entries)
但我怎么添加的消息,并权威性?


解决方案

  requests.post(https://test.com/api/v1/courses/xx/discussion_topics/xx /entries.json,数据= json.dumps({消息:<&消息GT;}),标题= {授权:承载<令牌GT;})

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>"

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>"}) 

这篇关于卷曲转换到Python要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆