0
0
Rest APIprogramming~10 mins

Async batch processing in Rest API - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start an asynchronous batch job.

Rest API
response = client.post('/batch/start', json=[1])
Drag options to blanks, or click blank then click option'
Atasks_list
B['tasks']
C{'tasks': tasks_list}
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the tasks list directly without wrapping in a dictionary.
2fill in blank
medium

Complete the code to check the batch job status asynchronously.

Rest API
status = client.get(f'/batch/status/[1]').json()
Drag options to blanks, or click blank then click option'
Abatch_id
Bjob_id
Ctask_id
Drequest_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using task_id or request_id instead of batch_id.
3fill in blank
hard

Fix the error in the code to correctly retrieve batch results asynchronously.

Rest API
results = client.get(f'/batch/results/[1]').json()['[2]']
Drag options to blanks, or click blank then click option'
Adata
Bresults
Cbatch_id
Dtask_results
Attempts:
3 left
💡 Hint
Common Mistakes
Using task ID instead of batch ID.
Using wrong JSON key to access results.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that filters completed tasks with results.

Rest API
completed_tasks = {task['id']: task['result'] for task in tasks if task['status'] [1] 'completed' and task['result'] [2] None}
Drag options to blanks, or click blank then click option'
A==
B!=
C<
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operators causing incorrect filtering.
5fill in blank
hard

Fill all three blanks to build a dictionary of task IDs and their results for tasks with errors.

Rest API
error_tasks = {task['id']: task['error_message'] for task in tasks if task['status'] [2] 'error' and task.get('{{BLANK_3}}') is not None}
Drag options to blanks, or click blank then click option'
A{task['id']: task['error_message']}
B==
C'error_message'
D[task['id'], task['error_message']]
Attempts:
3 left
💡 Hint
Common Mistakes
Using list instead of dictionary comprehension.
Wrong status check operator.