First off, I am totally new to REST API's and Python 🙃
Â
I am trying to piece together an automated export of a Trello board and have looked through the code offerings of some other users: trello-python-demo/demo_bc_org_backup.py at 57f57b4577a3179650b3421cb4f299394828d337 · bmccormack/trello-python-demo · GitHub, Atlassian documentation.
Â
I currently have this written and making a POST but I am getting a "unauthorized organization" error. Any thoughts on what I might be doing wrong? (I am not a business class user myself, but I am part of a team)
Â
# This code sample uses the 'requests' library:
# http://docs.python-requests.org
import requests
import json
# Set key and token here or get it from settings.py (preferred)
key = ''
# if you're storing your key in this file, you don't need the following three lines
if not key:
from settings import trello_key
key = trello_key
token = ''
# if you're storing your token in this file, you don't need the following three lines
if not token:
from settings import trello_token
token = trello_token
board = ''
# if you're storing your token in this file, you don't need the following three lines
if not board:
from settings import master_id
board = master_id
org = ''
# if you're storing your token in this file, you don't need the following three lines
if not org:
from settings import org_id
org = org_id
# CREATE EXPORTS
# get boards
#url = "https://api.trello.com/1/boards/%s/cards" % (board)
# get org export
url = "https://api.trello.com/1/organizations/%s/exports" % (org)
headers = {
"Accept": "application/json"
}
query = {
'key': key,
'token': token,
}
response = requests.request(
"POST",
url,
headers=headers,
params=query
)
#response = requests.request(
# "GET",
# url,
# headers=headers,
# params=query
#)
# Simple text return for testing
print(response.text)
# print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
Â