How to Run QPAPI with CURL

QPAPI provides a powerful interface to interact with Qmanager. This guide will show you how to perform GET, POST, and PUT requests using curl.

Prerequisites

  • Ensure you have curl installed on your system.

  • Replace https://{YOUR_HOSTNAME}:8080 with the appropriate base URL of your Qmanager instance.

  • Replace YOUR_AUTH_TOKEN with your actual authorization token.

For the authentication token, please refer to Authentication

Common Headers

You'll typically use the following headers in your requests:

  • Content-Type: application/json

  • Authorization: Basic <YOUR_AUTH_TOKEN>

GET Request

Use the GET request to retrieve data from the server.

Example

curl --location --request GET 'https://qp100g:8080/api/v1/capture/is_capturing' \ --header 'Authorization: Basic YOUR_AUTH_TOKEN'

POST Request

Use the POST request to create a new resource.

Example

curl --location 'https://qp100g:8080/api/v1/search/date_time_search' \ --header 'Authorization: Basic YOUR_AUTH_TOKEN' \ --form 'start_time="2023/02/03 10:49:00"' \ --form 'end_time="2023/02/03 10:50:00"' \ --form 'syntax="tcp"' \ --form 'expression="google"' \ --form 'capture_directory="/cifs/capture/records/Port0"'

PUT Request

Use the PUT request to update an existing resource.

Example

curl --location --request PUT 'https://qp100g:8080/api/v1/capture/capture_settings?port=0' \ --header 'Content-Type: application/json' \ --header 'Authorization: Basic YOUR_AUTH_TOKEN' \ --data '{ "Filename": "20200213_144347", "CapDir": "/cifs/capture/records/Port0", "SegmentSize": "bysize", "Bytesize": "1000", "Sizeunit": "MB", "compress": "false", "Rotation": "on", "Merge_Ports": "off", "Filtering_Enable": "off", }'