curl and POST, GET, PUT, DELETE

Make requests with data:
Since we learn how to make POST, GET, PUT, DELETE requests, we can now make same requests with data. In order to send data with those requests, we should use –data parameter. Here are some examples:

::::/bin/bash
# send login data with POST request
curl –request POST ‘http://www.linuxhow.tk/login/’ \
–data ‘username=myusername&password=mypassword’

# send search data to with get request
curl –request GET ‘http://www.linuxhow.tk/results?search_query=my_keyword’

# send PUT request with data
curl –request PUT ‘http://www.linuxhow.tk/rest-api/user/12345/’\
–data ’[email protected]

# same thing but this one get data from a file named data.txt
curl –request PUT ‘http://www.linuxhow.tk/user/12345/’\
–data @data.txt

Leave a Reply

Your email address will not be published. Required fields are marked *