将所有活动的 twilio Flow 更新为结束错误

Updating all active twilio Flow to ended error

所以我想运行这个pythong脚本来结束当前正在执行的所有活动流

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)

我收到这个错误 "'ExecutionContext' object has no attribute 'update'" 我想结束 Twilio 流程,但 twilio 网站上的文档在这种情况下对我不起作用。

此处为 Twilio 开发人员布道师。

由于您在从 API 中列出执行时已经收集了执行,因此您应该能够使用该对象来更新状态。试试这个:

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)