我正嘗試在燒瓶中發送發佈請求。在燒瓶中發送發佈請求
我想發送帶有Content-Type: application/json
設置爲標頭的json對象。
我與請求如下這樣模塊:
json_fcm_data = {"data":[{'key':app.config['FCM_APP_TOKEN']}], "notification":[{'title':'Wyslalem cos z serwera', 'body':'Me'}], "to":User.query.filter_by(id=2).first().fcm_token}
json_string = json.dumps(json_fcm_data)
print json_string
res = requests.post('https://fcm.googleapis.com/fcm/send', json=json_string)
但是這給了我:
TypeError: request() got an unexpected keyword argument 'json'
就如何解決這一問題有何意見?
通'數據= json_string' –
但不要把它設置「內容類型:應用程序/ JSON」? – demoo
有3個屬性,'header','param'和'data'。要設置標題變量像'content-type',你應該在標題 –