How to import a json file in trello

Pedro Merino Govela
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 27, 2024

 

 

I have a new dashboard in a different account and I want to import the old dashboard from my old account.

1 answer

1 vote
Alonso Rojas June 27, 2024

Hello Pedro

 

If I'm not mistaken, importing a JSON file directly into Trello is not supported natively. However, you can use a combination of Trello's API and some code to import the JSON data from your old dashboard into your new Trello board

Something like this could work:

import json
import requests

# Your API credentials
API_KEY = 'your_api_key'
TOKEN = 'your_api_token'

# New Trello board details
BOARD_ID = 'your_new_board_id'

# Load JSON data
with open('path_to_your_json_file.json', 'r') as file:
data = json.load(file)

# Function to create a list
def create_list(name, board_id):
url = f"https://api.trello.com/1/lists?name={name}&idBoard={board_id}&key={API_KEY}&token={TOKEN}"
response = requests.post(url)
return response.json()['id']

# Function to create a card
def create_card(name, desc, list_id):
url = f"https://api.trello.com/1/cards?name={name}&desc={desc}&idList={list_id}&key={API_KEY}&token={TOKEN}"
response = requests.post(url)
return response.json()

# Create lists and cards on the new board
for list_data in data['lists']:
list_name = list_data['name']
list_id = create_list(list_name, BOARD_ID)
for card in data['cards']:
if card['idList'] == list_data['id']:
card_name = card['name']
card_desc = card.get('desc', '')
create_card(card_name, card_desc, list_id)

print("Import completed successfully.")

 

I hope this helps you.

Alonso.-

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events