Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a new HTTP GET request using UrlFetchApp.
Google Sheets
var response = UrlFetchApp.[1]('https://api.example.com/data');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' or 'request' which are not valid methods in UrlFetchApp.
Trying to call a method that does not exist.
✗ Incorrect
The correct method to make an HTTP request in Apps Script is fetch.
2fill in blank
mediumComplete the code to parse the JSON response text into an object.
Google Sheets
var data = JSON.[1](response.getContentText()); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'stringify' which converts objects to JSON text.
Using non-existent methods like 'convert' or 'toObject'.
✗ Incorrect
Use JSON.parse to convert JSON text into a JavaScript object.
3fill in blank
hardFix the error in the code to set the HTTP method to POST in the options object.
Google Sheets
var options = {method: '[1]', contentType: 'application/json'}; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'post' which may not work.
Using wrong method names like 'Get' or 'Put'.
✗ Incorrect
The HTTP method must be uppercase 'POST' to be recognized correctly.
4fill in blank
hardFill both blanks to create a POST request with JSON payload.
Google Sheets
var options = {method: '[1]', payload: JSON.[2](data)}; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET method when sending data.
Using JSON.parse instead of stringify for payload.
✗ Incorrect
Use POST as method and JSON.stringify to convert data to JSON text for payload.
5fill in blank
hardFill all three blanks to extract a value from the JSON response and set it in a sheet cell.
Google Sheets
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('[1]'); sheet.getRange([2], [3]).setValue(data.result);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong sheet names.
Using zero or invalid row/column numbers.
✗ Incorrect
Use the sheet named 'Data', set value at row 1, column 2 to the result from data.