使用响应对python进行卷曲
我试图使用使用响应对python进行卷曲,python,curl,request,Python,Curl,Request,我试图使用请求模块在python中复制下面的curl命令。curl命令如下: curl -X POST "https://api.appcenter.ms/v0.1/apps/{username}/{appname}/push/notifications" -H "accept: application/json" -H "X-API-Token: Token" -H "Content-Type: application/json" -d "{ \"notification_target
请求
模块在python中复制下面的curl
命令。curl
命令如下:
curl -X POST "https://api.appcenter.ms/v0.1/apps/{username}/{appname}/push/notifications" -H "accept: application/json" -H "X-API-Token: Token" -H "Content-Type: application/json" -d "{ \"notification_target\": null, \"notification_content\": { \"name\": \"Nazwa\", \"title\": \"Lampa\", \"body\": \"Została wyłączona\" }}"
我尝试了下面的代码,但返回代码400
import requests
h={'accept': 'application/json', 'X-API-Token':'TOKEN','Content-Type':'application/json'}
d={'\"notification_target\": null, \"notification_content\": { \"name\": \"Nazwa\", \"title\": \"Lampa\", \"body\": \"Została wyłączona\"'}
r = requests.post("https://api.appcenter.ms/v0.1/apps/{username}/{appname}/push/notifications", data=d, headers=h)
问题是python中的“null”,我必须不写任何东西,而且一切都正常:)那么,到目前为止你完成了什么?有错误吗?向我们展示您的代码。将您的数据定义为dict并使用json关键字。