Use CURL library to get token and lists in Magento2
Use CURL Library to get the token and customer list in Magento2
In the below code we will see how to get the token by excuting CURL command , this will be very helpfull to check the endpoints before we start working on any request
curl -X POST "https://example.com/index.php/rest/V1/integration/admin/token" -H "Content-Type:application/json" -d "{\"username\":\"username\", \"password\":\"password\"}"
after you get the token you can use it here
curl -X GET "https://example.com/index.php/rest/V1/orders?searchCriteria" -H "Authorization: Bearer u6q6ynzgpmww6i1mppjx3j8lnajn5u5e"
if you want to use brakets then you need to use this paramter –globoff
curl --globoff GET "https://example.com/index.php/rest/V1/orders?searchCriteria[currentPage]=1&searchCriteria[pageSize]=2" -H "Authorization: Bearer u6q6ynzgpmww6i1mppjx3j8lnajn5u5e"
More about Curl Click here
Use cURL to run the request
'cURL' is a command-line tool that lets you transmit HTTP requests and receive responses from the command line or a shell script. It is available for Linux distributions, Mac OS X, and Windows.
To use cURL to run your REST web API call, use the cURL command syntax to construct the command.
To create the endpoint in the call, append the REST URI that you constructed in Construct a request to this URL:
https://<MAGENTO_HOST_OR_IP>/<MAGENTO_BASE_INSTALL_DIR>/rest/
To pass the customer data object in the POST call payload, specify a JSON or XML request body on the call.
For a complete list of cURL command options, see curl.1 the man page.