How do I download the contents of a resource via API?

Modified on Fri, 5 Jul, 2024 at 3:13 PM

TABLE OF CONTENTS


Create API Token


First, from the top-left menu under "Tools & Resources" > "Tokens", create an API token with at least the "ResourceRead" capability



As the warning states, make sure you copy your token before it disappears; treat this as a password and save it somewhere safe



Gather Information


Next, from the top-left menu under "Tools & Resources" > "Resources", gather some information about your instance and target resource from the URL bar of your browser



Webserver: 172.28.17.6 (or hostname)

Resource GUID: e51d84b1-b57d-4a83-9665-64662c823a5c

(Optional) Filename: resource.csv


Download target resource


Bash

/usr/bin/curl -H "Gravwell-Token: $TOKEN" "http://$WEBSERVER/api/resources/$GUID/raw" -o FILENAME -s

 

Powershell (curl)

C:\windows\system32\curl -H "Gravwell-Token: $TOKEN" "http://$WEBSERVER/api/resources/$GUID/raw" -o $FILENAME -s

Remove "-o $FILENAME" if you don't want to save the contents of the target resource to a local file

Remove "-s" if you want to output connection information to the terminal


Powershell (Invoke-WebRequest)

Invoke-WebRequest -Headers @{"Gravwell-Token" = "$TOKEN"} -Uri "http://$WEBSERVER/api/resources/3c8598fc-9fc7-4034-9060-f308e70a34fe/raw" -OutFile $FILENAME

Remove "-OutFile $FILENAME" if you don't want to save the contents of the target resource to a local file




Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article