0
0
Rest APIprogramming~10 mins

Batch update patterns 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 specify the HTTP method for batch updating resources.

Rest API
fetch('/api/items/batch', { method: '[1]', body: JSON.stringify(data) })
Drag options to blanks, or click blank then click option'
APUT
BGET
CPOST
DDELETE
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET or DELETE methods for updating data.
2fill in blank
medium

Complete the code to set the correct Content-Type header for sending JSON data in a batch update request.

Rest API
fetch('/api/items/batch', { method: 'PUT', headers: { 'Content-Type': '[1]' }, body: JSON.stringify(data) })
Drag options to blanks, or click blank then click option'
Amultipart/form-data
Btext/plain
Capplication/xml
Dapplication/json
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect Content-Type headers like text/plain or application/xml.
3fill in blank
hard

Fix the error in the batch update request by choosing the correct URL path segment for batch operations.

Rest API
fetch('/api/items/[1]', { method: 'PUT', body: JSON.stringify(data) })
Drag options to blanks, or click blank then click option'
Abatch
Bmodify
Cchange
Dupdate
Attempts:
3 left
💡 Hint
Common Mistakes
Using vague or uncommon path segments like 'update' or 'change'.
4fill in blank
hard

Fill both blanks to create a batch update request that sends an array of items and expects a JSON response.

Rest API
fetch('/api/items/batch', { method: '[1]', headers: { 'Content-Type': '[2]' }, body: JSON.stringify(items) })
Drag options to blanks, or click blank then click option'
APUT
Bapplication/json
CPOST
Dtext/html
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST instead of PUT or wrong Content-Type headers.
5fill in blank
hard

Fill all three blanks to handle a batch update with error checking and JSON response parsing.

Rest API
async function batchUpdate(items) {
  const response = await fetch('/api/items/batch', {
    method: '[1]',
    headers: { 'Content-Type': '[2]' },
    body: JSON.stringify(items)
  });
  if (!response.ok) throw new Error('Batch update failed');
  const result = await response.[3]();
  return result;
}
Drag options to blanks, or click blank then click option'
APUT
Bapplication/json
Cjson
Dtext
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST instead of PUT, wrong Content-Type, or parsing response as text.