0
0
Bash Scriptingscripting~5 mins

HTTP requests with curl in scripts in Bash Scripting - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the basic command to make a GET request using curl?
The basic command is curl URL. This sends a GET request to the URL and shows the response.
Click to reveal answer
beginner
How do you include headers in a curl request?
Use the -H option followed by the header in quotes. Example: curl -H "Content-Type: application/json" URL.
Click to reveal answer
beginner
How can you send data with a POST request using curl?
Use -d to send data and -X POST to specify POST method. Example: curl -X POST -d "name=John" URL.
Click to reveal answer
beginner
What option makes curl silent, so it doesn't show progress or errors?
Use -s or --silent. This is useful in scripts to avoid clutter.
Click to reveal answer
beginner
How do you save the response of a curl request to a file?
Use -o filename to save the output to a file. Example: curl URL -o response.txt.
Click to reveal answer
Which curl option is used to add a custom header to an HTTP request?
A-d
B-H
C-X
D-s
What does the -d option do in a curl command?
ASets the HTTP method
BAdds a header
CSends data in the request body
DMakes curl silent
How do you specify a POST request explicitly with curl?
A-X POST
B-H POST
C-d POST
D-s POST
Which option saves the response to a file?
A-o filename
B-s filename
C-H filename
D-d filename
What does the -s option do in curl?
AAdds a header
BSends data
CSpecifies HTTP method
DRuns curl silently without progress or errors
Explain how to make a POST request with JSON data using curl in a script.
Think about method, headers, and data options.
You got /4 concepts.
    Describe how to save the output of a curl HTTP GET request to a file silently.
    Combine silent mode and output file options.
    You got /4 concepts.