Call Structure
When sending requests using cURL, each command must begin with the curl command followed by the -X option, which specifies the HTTPS request method (such as GET, POST, or DELETE). This option tells the server what action to perform on the specified resource. For example:
curl -X 'request-type' |
Request type | Description |
---|---|
GET | Fetches data from the server |
POST | Sends data to the server to create a new resource |
DELETE | Removes a resource from the server |
PATCH | Sends data to partially update an existing resource |
PUT | Sends data to update or replace an existing resource, or create it if it does not exist |
The next piece of information that will be required is the API endpoint, this information for each action can be found in the API Endpoints section of the manual
curl -X 'request-type' \ API-endpoint/ |
Data
The -d option (short for --data) is used to send data in the body of an HTTP request when using 'POST' or 'PATCH' requests. It allows you to include data in your request, such as form fields, JSON objects, or other data types, that the server expects to process.
curl -X 'POST' \ API-method/ -d '{data}' |
Headers and Authentication
The Product Name requires certain headers to be included in the request, such as an authentication token. cURL allows you to add these headers using the `-H` option.
curl -X 'request-type' \ API-method/ -H "Authorization: Bearer token" |
A token exchange will need to take place using custom services within the Cambrionix Connect platform, for more information on that please see the Token Exchange information.
Handling API Responses
The API will return responses in JSON format. cURL outputs the response directly to the terminal by default.