This repository contains a custom Google Apps Script that extends the ImportJSON
function to support Atlassian Cloud APIs (e.g., Jira Cloud, Confluence Cloud). By storing your Atlassian Cloud URL, email, and API token in Script Properties, you can easily import JSON data into a Google Sheet without exposing credentials in plain text.
- Language: Google Apps Script (JavaScript).
- Purpose: Retrieve JSON from Atlassian Cloud APIs using Basic Auth with API tokens.
- Key Functions:
ImportJSONAdvanced(url, query, options, email, token)
ImportJSON(url, query, options, email, token)
- Both can leverage script properties to avoid hard-coding credentials.
Live Example Sheet: Google Sheet with Script Attached
-
Open the Google Sheet
- Use the link above or make a copy of the sheet containing the script.
- Alternatively, you can copy the code from this repository into a new Apps Script project attached to your own Google Sheet.
-
Access the Script Editor
- In the Sheet, go to Extensions → Apps Script.
- This opens the Apps Script editor, where you can view/edit the
ImportJSON.gs
file.
-
Set Script Properties
In the Apps Script editor:- Click the gear icon (Project Settings) on the left or use the menu: Project → Project Properties.
- Locate Script Properties and click Open Script Properties.
- Create properties for:
url
– Your Atlassian Cloud URL, e.g.https://your-domain.atlassian.net/
.email
– The email you use for Atlassian Cloud.token
– Your Atlassian API token (generated from https://id.atlassian.com/manage/api-tokens).
Example:
url = https://your-domain.atlassian.net/ email = [email protected] token = abc123generatedapitoken
-
Confirm the Script is Available
- In the script code, ensure you see the
ImportJSON
andImportJSONAdvanced
functions. - Feel free to run a test function or open the logs (
View
→Logs
) to confirm the code is active.
- In the script code, ensure you see the
=ImportJSONAdvanced(
"https://your-domain.atlassian.net/rest/api/3/search?jql=project=MYPROJ",
"/issues",
"noHeaders",
"[email protected]",
"yourApiToken"
)
- URL: The Atlassian REST endpoint (Jira, Confluence, etc.).
- Query: Paths to import from the JSON.
- Options: Comma-separated (e.g.,
"noHeaders,noTruncate"
). - Email and Token: Atlassian credentials.
If you leave some (or all) parameters blank, the script will use whatever you set in url
, email
, and token
in Script Properties. For example:
=ImportJSONAdvanced(
"",
"/issues",
"",
"",
""
)
- A blank
url
falls back tourl
from Script Properties. - Blank
email
/token
fallback toemail
andtoken
.
- Logs: Use
Logger.log(...)
in Apps Script to see debug output:- Run your function (e.g.,
=ImportJSONAdvanced(...)
) in the spreadsheet. - Switch to the script editor and go to View → Logs.
- Run your function (e.g.,
- Check the HTTP status: Ensure you get
200
for success.401
or403
typically indicate invalid credentials.
- 401 / 403: Check that
email
andtoken
are correct in script properties. - Limitations: By default, Atlassian APIs can page data (e.g., Jira might only return 50–100 issues at a time). You may need to handle pagination or specify
maxResults
. - Rate Limits: Atlassian Cloud may enforce rate limits. If you see HTTP
429
, consider throttling requests or narrowing your search queries.
- Fork the repository and clone it to your local machine.
- Make changes or improvements to the script.
- Submit a pull request if you have enhancements or bug fixes.
This project is based on the original ImportJSON library by Trevor Lohrbeer. See LICENSE for details, typically GPL-3.0 or similar.
For any organization-specific usage, ensure you comply with Atlassian’s API terms and your company’s data security policies.
Happy importing! If you have any questions, open an issue on GitHub or contact your Atlassian administrator for additional details on API tokens and project configuration.