Hello @ChrisNemes,
group_id
and item_name
are supposed to be a strings
Try this:
mutation { create_item (board_id:1913125449, item_name: "Teszt2", group_id: "topics",create_labels_if_missing: true, column_values:"{\\"status\\":{\\"label\\":\\"Medium\\"}}") {
id
}}
Tried your solution, and I got the same error:
query3 = 'mutation { create_item (board_id:1913125449, item_name: "Teszt2", group_id: "topics",create_labels_if_missing: true, column_values:"{\\"status\\":{\\"label\\":\\"Medium\\"}}") { id}}'
Result:
{'errors': [{'message': 'Parse error on ":{" (STRING) at [1, 138]', 'locations': [{'line': 1, 'column': 138}]}], 'account_id': 10454884}
I’m using the API in python, if it counts.
Sorry, I’m not conversant in Python but the solution I provided works. I’ve tested it in the playground.
Thank you for your efforts! 🙂
Finally I managed to make one function that works:
createItemWithData(board_id, vars, groupID)
It uses 3 variables:
- the board_id comes from the board where the item will be created
- the vars stores all the variables/attributes/column values the item has
- groupID is used for grouping items in boards
vars looks like this:
vars = {
'myItemName': "MyItem",
'columnVals': json.dumps({
'username': "Chris",
'task': "That is my job",
'starttime': {"hour": int(01), "minute": int(13)},
'endtime': {"hour": int(03), "minute": int(35)},
})
}
The column ID-s are username, task, starttime and endtime.
and the function:
def createItemWithDataJob(board_id, vars, groupID):
'''Creating items with column values'''
try:
query = 'mutation ($myItemName: String!, $columnVals: JSON!) { create_item (board_id:' + str(board_id) + ', group_id: ' + str(groupID) + ', item_name:$myItemName, column_values:$columnVals) { id } }'
data = {'query': query, 'variables': vars}
r = requests.post(url=apiUrl, json=data, headers=headers) # make request
print(r.json())
except Exception as e:
print("Something is wrong...")
print(e)
exit()
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.