To pull data from the Salesforce API to Google Sheets, first install and open the Apipheny Google Sheets add-on.
Apipheny is an easy to use API integrator for Google Sheets that you can use to make unlimited API requests, connect to unlimited APIs, save API requests, schedule API requests, and more. Click here for more info about Apipheny.
1. Install Apipheny by opening the following link on desktop and then clicking the Install button on the next page: https://gsuite.google.com/marketplace/app/apipheny/966163326746
2. After you’ve installed Apipheny, open a Google Sheet and then click on the Add-Ons option in the top menu. In the add-ons menu, you should see Apipheny.
Click Apipheny > Import API to open the Apipheny sidebar in your Google Sheets, like so:
4. Choose the scopes you want to use:
5. Click the Save button to finally create the app:
6. Change the IP Relaxation Setting:
Go to Apps = > App Manager and find your app. Click the corresponding arrow and choose Manage from the drop-down menu:
Click the Edit Policies button:
Change the IP Relaxation setting to Relax IP restrictions:
In your console window, write the command below to obtain a token:
curl -s -X POST -F grant_type=password -F client_id=YOUR_CLIENT_ID -F client_secret=YOUR_CLIENT_SECRET -F username=YOUR_USERNAME -F password=YOUR_PASSWORD https://login.salesforce.com/services/oauth2/token
You’ll need to fill in a few parts:
Executing this command will return your access token in the response:
Copy and paste this new token to safe place because you’ll need it in the next steps.
In this section, we’ll show you how to browse the Salesforce API documentation to find the Salesforce API URL that retrieves the information you need from your Salesforce account. If you already know your URL, or you want to use the same example URL as us, just skip to Step 5.
First, open the Salesforce API documentation page: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_list.htm
The main part pf the page contains the basic URL that you should use, a table containing the endpoints, and a short description for each endpoint:
An example endpoint is Resources by Version, that lists available resources for the specified API version, including resource name and URI. This is the corresponding URL for that endpoint:
If you use this URL, don’t forget to replace yourInstance with your domain name.
The documentation for each endpoint contains a short description of the endpoint’s purpose, the URI, the response format (JSON, XML), the endpoint’s HTTP method (GET), the authentication method, and a list of the accepted API parameters:
Now go back to your Google Sheet and make sure that the Apipheny add-on is open on the “Import” tab. With the Import tab open, enter these details into the add-on:
API URL: In Step 4, we explained how you can find the Salesforce REST API endpoint that you need. Now copy and paste your complete Salesforce API URL into the Apipheny add-on, where it says API URL Path, followed by any parameters required for your query (if applicable).
For this example, we are using the Account Info endpoint, that retrieves basic information about an Account object. This is what the whole URL looks like:
If you’re following this same example as us, just replace YOUR_INSTANCE with the domain you are using.
Headers: In the Headers section of the Apipheny add-on, add two API header rows with the following keys and values (if you’re following the same example as us):
Header 1 Key: Authorization Value: Bearer <your_token> Header 2 Key: X-PrettyPrint Value: 1
<your_token> is the value of the token you obtained previously, in Step 3. There should be a literal space between Bearer and <your_token>.
Finally, the last step is to click the Run button at the bottom of the Apipheny add-on and then wait for the Salesforce API data to be imported into your Google Sheet.
After making a successful request to the Salesforce API, try querying a different Salesforce API endpoint, or try using one of the more advanced features in the Apipheny add-on, such as: