tab/python_api_example/transactions.py
2019-04-12 11:33:13 +02:00

20 lines
417 B
Python

import requests
base_url = 'http://localhost:3000'
user = 'j'
user_token = '1idEG5bFVVjUcl+15Y1DsQ=='
headers = {'Authorization': f'Token token={user_token}'}
data = {
'transaction': {
'euros': 5.0,
'message': 'Transaction from Python',
'debtor': user,
'creditor': 'Zeus'
}
}
r = requests.post((base_url + f'/transactions.json'), headers=headers, json=data)
print(r.text)