onejgordon / flow-dashboard

[UNMAINTAINED] A goal, task & habit tracker + personal dashboard to focus on what matters
http://flowdash.co
MIT License
1.66k stars 187 forks source link

Api tracking #117

Closed NicoCaro closed 5 years ago

NicoCaro commented 6 years ago

I'm trying to track a test variable thought the tracking Api . The documentation isn't enough for me to understand the methods. So far I can authenticate successfully (get method displays code [200] ), but just can´t post any data, here there is a code example, I'm trying to post data from python 3.6 with the requests library:

import base64
import json
import requests

user_encoded = base64.b64encode(b'USER_MAIL').decode()
pass_encoded = base64.b64encode(b'API_PASS').decode()

url_base = 'https://flowdash.co/api/tracking/'

DATE = '2018-06-06'

data_dict = {
  'date': '2018-09-06',
  'data': json.dumps({'test':1})
}

data_json = json.dumps(data_dict)

# Direct request
r_0 = requests.post(url_base,{'date': DATE, 'data': json.dumps({'foo': 'bar'})},auth=(user_encoded,pass_encoded))

# Dict Request
r_1 = requests.post(url_base,data=data_dict,auth=(user_encoded,pass_encoded))

# Json Request
r_2 = requests.post(url_base,json=data_json,auth=(user_encoded,pass_encoded))

print('r_0',r_0)
print('r_1',r_1)
print('r_2',r_2)

For the 3 requests i get:

r_0 <Response [405]> r_1 <Response [405]> r_2 <Response [405]>

Sorry if this isn't the right place to ask this question but I didn't know where else to ask it.