Change multiple column values in Python

I think this is the same problem I had when using json.dumps in python, it’s not escaping the quotes as required by graphql, I managed to fix it by using a nested json.dumps like so :

>>> import json
>>> status = 'Hello'
>>> json.dumps({'label':status})
'{"label": "Hello"}'
>>> json.dumps(json.dumps({'label':status}))
'"{\\"label\\": \\"Hello\\"}"'
>>>

That way, I could have my the following function work :

def update_status(board, event_id, status_id, status):
    status = json.dumps(json.dumps({'label':status}))
    query = f'''mutation {{
                change_column_value(
                    board_id:{board},
                    item_id:{event_id},
                    column_id:{status_id},
                    value: {status})
                    {{id}}
            }}'''
    return {'query': query}

I hope this helps!

1 Like