0
0
IOT Protocolsdevops~10 mins

RESTful API design for devices in IOT Protocols - 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 retrieving device data.

IOT Protocols
curl -X [1] http://api.example.com/devices/123
Drag options to blanks, or click blank then click option'
APOST
BGET
CDELETE
DPUT
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST instead of GET to retrieve data.
Confusing DELETE with GET.
2fill in blank
medium

Complete the code to update device settings using the correct HTTP method.

IOT Protocols
curl -X [1] -d '{"mode":"eco"}' http://api.example.com/devices/123/settings
Drag options to blanks, or click blank then click option'
AHEAD
BGET
CPUT
DDELETE
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET instead of PUT for updates.
Using DELETE when intending to update.
3fill in blank
hard

Fix the error in the API endpoint to correctly delete a device.

IOT Protocols
curl -X DELETE http://api.example.com/devices/[1]
Drag options to blanks, or click blank then click option'
A123
Bdevice_id
Csettings
Dupdate
Attempts:
3 left
💡 Hint
Common Mistakes
Using a placeholder name instead of the actual device ID.
Using 'settings' or 'update' in the URL when deleting.
4fill in blank
hard

Fill both blanks to create a JSON response showing device status and battery level.

IOT Protocols
{
  "status": "[1]",
  "battery": [2]
}
Drag options to blanks, or click blank then click option'
Aonline
Boffline
C85
D100
Attempts:
3 left
💡 Hint
Common Mistakes
Putting battery level in quotes making it a string.
Using 'offline' when the device is online.
5fill in blank
hard

Fill all three blanks to define a RESTful API route for creating a new device with POST method.

IOT Protocols
POST [1] HTTP/1.1
Host: api.example.com
Content-Type: [2]

[3]
Drag options to blanks, or click blank then click option'
A/devices
Bapplication/json
C{"name":"SensorX","type":"temperature"}
D/device
Attempts:
3 left
💡 Hint
Common Mistakes
Using singular '/device' instead of '/devices'.
Wrong content type like 'text/plain'.
Missing or invalid JSON body.