0
0
Bash Scriptingscripting~10 mins

API interaction scripts in Bash Scripting - Interactive Code Practice

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

Complete the code to send a GET request to example.com using curl.

Bash Scripting
curl [1] https://example.com
Drag options to blanks, or click blank then click option'
A-X GET
B-X POST
C-d
D-I
Attempts:
3 left
💡 Hint
Common Mistakes
Using -X POST instead of -X GET causes the server to expect data submission.
Using -d without data causes errors.
Using -I only fetches headers, not the full response.
2fill in blank
medium

Complete the code to include a JSON content type header in the curl request.

Bash Scripting
curl -X POST [1] -d '{"name":"John"}' https://example.com/api
Drag options to blanks, or click blank then click option'
A-H 'Content-Type: text/plain'
B-H 'Content-Type: application/json'
C-H 'Accept: text/html'
D-H 'Authorization: Bearer token'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong Content-Type header causes the server to misinterpret the data.
Forgetting to add the header can cause the server to reject the request.
3fill in blank
hard

Fix the error in the curl command to correctly send a POST request with JSON data.

Bash Scripting
curl -X POST -d [1] https://example.com/api
Drag options to blanks, or click blank then click option'
A'name=John'
B"name: John"
C"name=John"
D'{"name":"John"}'
Attempts:
3 left
💡 Hint
Common Mistakes
Using key=value format instead of JSON.
Using double quotes outside without escaping causes shell errors.
4fill in blank
hard

Fill both blanks to save the response headers to a file and the body to another file.

Bash Scripting
curl -D [1] -o [2] https://example.com/api
Drag options to blanks, or click blank then click option'
Aheaders.txt
Bresponse.json
Coutput.log
Ddata.txt
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing -D and -o options.
Saving both headers and body to the same file.
5fill in blank
hard

Fill all three blanks to create a curl command that sends a DELETE request with an authorization header and verbose output.

Bash Scripting
curl [1] [2] [3] https://example.com/api/item/123
Drag options to blanks, or click blank then click option'
A-X DELETE
B-H 'Authorization: Bearer abc123'
C-v
D-d '{}'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to specify the DELETE method.
Not including the authorization header.
Missing verbose flag for debugging.