Download report file

This code snippet shows you how to retrieve a report file. The report file is a Zipped CSV file containing all the records for the request.

Example

Variable Required Description
VONAGE_API_KEY Yes Your API key which you can obtain from your Dashboard.
VONAGE_API_SECRET Yes Your API secret which you can obtain from your Dashboard.
FILE_ID Yes The file ID of the report to retrieve.

Write the code

Add the following to get-report.sh:

Copy to Clipboard
curl -o report.zip -u "$VONAGE_API_KEY:$VONAGE_API_SECRET" \
     "https://api.nexmo.com/v3/media/$FILE_ID"

View full source

Run your code

Save this file to your machine and run it:

bash get-report.sh

Try it out

  1. Set the replaceable variables for your account.
  2. Set the FILE_ID. You can obtain this from the details of a get report status or list reports call. The response will contain JSON similar to:

    Copy to Clipboard
        "download_report": {
        "href": "https://api.nexmo.com/v3/media/84a14d67-1234-5678-9012-ac042b16092a"
        }
    

    In this case 84a14d67-1234-5678-9012-ac042b16092a is the FILE_ID.

  3. Run the script to download a Zip file containing the report in CSV format.

See also