Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to select only the 'name' field in the API request.
Rest API
GET /users?fields=[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'all' returns all fields, not sparse fields.
Using 'id' or 'email' selects different fields, not 'name'.
✗ Incorrect
Using fields=name tells the API to return only the 'name' field for each user.
2fill in blank
mediumComplete the code to select both 'name' and 'email' fields in the API request.
Rest API
GET /users?fields=[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using semicolons or spaces instead of commas.
Reversing the order is okay but must use commas.
✗ Incorrect
The fields parameter uses commas to separate multiple fields. So fields=name,email selects both 'name' and 'email'.
3fill in blank
hardFix the error in the code to correctly select the 'title' field for posts.
Rest API
GET /posts?fields=[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using semicolons instead of commas.
Selecting multiple fields when only one is needed.
✗ Incorrect
To select only the 'title' field, use fields=title. Using semicolons or multiple fields selects more than just 'title'.
4fill in blank
hardComplete the code to select 'id' and 'username' fields for users.
Rest API
GET /users?fields=[1],username Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using semicolons instead of commas.
Not adding a separator between fields.
✗ Incorrect
So
id and , before 'username' are needed.5fill in blank
hardComplete the code to select 'author', 'date', and 'summary' fields for articles.
Rest API
GET /articles?fields=[1],date,summary Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using semicolons instead of commas.
Missing commas between fields.
✗ Incorrect
Using semicolons is incorrect, so blanks should be filled with 'author' and ',' to form the correct string.