0

So I want to run this pythong script to end all active Flows currently executing

executions = client.studio \
            .v1 \
            .flows('FWXXXXXX') \
            .executions \
            .list(limit=20)

for record in executions:
   if record.status == 'active':
       execution = client.studio \
                    .flows('FWXXXXXX') \
                    .executions(record.sid) \
                    .update(status='ended')
       print('ending', execution)

I get this error "'ExecutionContext' object has no attribute 'update'" I want to end a Twilio flow, but the documentation on the twilio website does not work for me in this case.

anupamb
  • 37
  • 8

1 Answers1

1

Twilio developer evangelist here.

Since you have already collected the executions when you list them from the API, you should be able to use that object to update the status. Try this:

executions = client.studio \
            .v1 \
            .flows('FWXXXXXX') \
            .executions \
            .list(limit=20)

for record in executions:
    if record.status == 'active':
        record.update(status='ended')
        print('ending', record)   
philnash
  • 70,667
  • 10
  • 60
  • 88
  • I tried it, though its a better shorthand. I still do get this. 'ExecutionInstance' object has no attribute 'update' Is there something up with my flow? – anupamb Nov 05 '21 at 12:41
  • Or is this some admin permission that doesn't allow me to update for some reason – anupamb Nov 05 '21 at 12:43
  • What version of the Python library are you using? – philnash Nov 05 '21 at 14:08
  • 3.7. But i think its because I have a version of twilio v1 working, updating to twilio 7.3.0 worked for me! the code you gave works. – anupamb Nov 05 '21 at 16:12