How to download Salesforce Event Log File using REST API?

How to download Salesforce Event Log File using REST API?

We can download Salesforce Event Log Files using the REST API.

First, we have to create a Connected App in Salesforce since we are going to use the REST API. Callback URL should be https://{Your Domain}.my.salesforce.com/services/oauth2/callback.

Example:

https://test-ec-dev-ed.develop.my.salesforce.com/services/oauth2/callback

Option 1: cURL Commands

1. Make a POST Request to get the access_token.

curl -v https://test-ec-dev-ed.develop.my.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=<CONSUMER KEY FROM CONNECTED APP>" -d "client_secret=<CONSUMER SECRET FROM CONNECTED APP" -d "username=<SALESFORCE USERNAME>" -d "password=<SALESFORCE PASSWORD>"

2. Use the access_token from the above request in the below request to download the Event Log Files.

curl https://test-ec-dev-ed.develop.my.salesforce.com/services/data/v58.0/sobjects/EventLogFile/0AT3t00000hcvWrGAI/LogFile -H "Authorization: Bearer <ACCESS TOKEN FROM STEP 1>" -H "X-PrettyPrint:1" -H "Content-Encoding:gzip" -o outputLogFile.csv 

Option 2: PostMan

1. Get the Access token.

Endpoint URL:

https://test-ec-dev-ed.develop.my.salesforce.com/services/oauth2/token

2. Use the Access Token from Step 2 and make a GET request to download the Salesforce Event Log File.

Endpoint URL:

https://test-ec-dev-ed.develop.my.salesforce.com/services/data/v58.0/sobjects/EventLogFile/0AT3t00000hcvWrGAI/LogFile/

Leave a Reply