0
我正在使用dashing.io儀表板,我想用python中的請求庫發出一個post請求,把數據放在一個小部件中。daching儀表板的Api鍵
但它一直給我發回一個401錯誤和一個無效的API密鑰。我不明白爲什麼,也沒有真正明白auth_token和api密鑰之間的區別。
這裏是我的代碼:
import json
import requests
dashboard_url = "http://localhost:3030"
widget_id = 'my_widget_id'
widget_url = dashboard_url + '/widgets/my_widget_id'
data = {'name' : 'thomas','id' : 'bonjour','city' : 'cerfontaine'}
data = json.dumps(data)
headers ={'Content-Type':'application/json', 'Accept':'text/plain',
'Authorization':'XYZ'}
try:
r = requests.post(widget_url, data, headers=headers)
print r.status_code
print r.json()
print r.text
except:
r = requests.post(widget_url, data, headers=headers)
print 'Dashing update failed'
print r.text
我在config.ru代碼的auth_token是XYZ了。 你們能幫我嗎?
你沒有發出正確的API密鑰 – 2014-10-02 15:11:02