I am trying to create an item on a board, then have the ID of the Item and create another Item in another board and link to items.
Here is the code that create the first Item and retrieves the Id of the new item:
new_client_name = 'test new client'
people = '774666386' # The Owner ID of the task
phone = '123456789'
email = 'email@email.com'
text0 = 'CEO' #Title
status4 = 'Kick Off' # Stage
date = datetime.today().strftime('%Y-%m-%d') # Created date
status = 'Customer' # Type of item - Customer / Other
dropdown = 'No' # Some Yes / No question
# # CREATE A NEW CLIENT
create_a_new_client = 'mutation ($myItemName: String!, $columnVals: JSON!) { create_item (board_id:1405312628, group_id:"1624094797_clients" item_name:$myItemName, column_values:$columnVals) { id } }'
vars = {
'myItemName' : new_client_name,
'columnVals' : json.dumps({
'people' : people,
'date' : {'date' : str(date)},
'phone' : phone,
'email' : {'email': email, 'text': email},
'text0' : text0,
'status4' : status4,
'status' : status,
'dropdown' : dropdown
})
}
data = {'query' : create_a_new_client, 'variables' : vars}
r = requests.post(url=apiUrl, json=data, headers=headers) # make request
new_item_id = r.json()['data']['create_item']['id']
And than I would like to create an item on another board and link it to the above Item:
## CREATE THE TASKS FOR NEW CUSTOMER
list_of_tasks = ['task1', 'task2']
## CREATE ITEMS IN AUTOMATED TASKS
for indx, tsk in enumerate(list_of_tasks):
dateforitem = datetime.today() + timedelta(days=indx)
# Check if Friday or Saturday
if dateforitem.weekday() == 4:
dateforitem = datetime.today() + timedelta(days=indx+2)
elif dateforitem.weekday() == 5:
dateforitem = datetime.today() + timedelta(days=indx+3)
# Change to correct format for Monday
dateforitem = dateforitem.strftime('%Y-%m-%d')
query5 = 'mutation ($myItemName: String!, $columnVals: JSON!) { create_item (board_id:3123123666, group_id:"next_week" item_name:$myItemName, column_values:$columnVals) { id } }'
vars = {
'myItemName' : str(dateforitem),
'columnVals' : json.dumps({
'date' : {'date' : str(dateforitem)}
})
}
data = {'query' : query5, 'variables' : vars}
r = requests.post(url=apiUrl, json=data, headers=headers) # make request
new_item_id_ie = r.json()['data']['create_item']['id']
query6 = '''mutation ($myItemiddd: String!, $columnVals: JSON!) {
change_multiple_column_values(item_id:$myItemiddd, board_id:3123123666, column_values: "{\\"contacts_1\\" : {\\"item_ids\\" : [$linktoitemid]}}") {
id
}
}'''
vars22 = {
'myItemiddd' : new_item_id_ie,
'linktoitemid' : new_item_id
}
data2 = {'query' : query6, 'variables' : vars22}
r = requests.post(url=apiUrl, json=data, headers=headers) # make request
print(r.json())
The Item were created but not linked to the original item…
Any Ideas?