import requests
AUTH_ENDPOINT = "https://auth.longenesis.com/realms/curator-engage/protocol/openid-connect/token"
USERNAME = "<your username>"
PASSWORD = "<your password>"
CLIENT_ID = "<Longenesis issued client id>"
CLIENT_SECRET = "<Longenesis issued client id>"
ENGAGE_ORG_SLUG = "<orgagization slug>"
ENGAGE_ACTIVITY_SLUG = "<activity slug>"
access_token = requests.post(
AUTH_ENDPOINT,
data={
"username": USERNAME,
"password": PASSWORD,
"grant_type": "password",
"client_id": CLIENT_ID,
"client_secret": CLIENT_SECRET,
},
).json()["access_token"]
response = requests.get(
f"https://engage-openapi.longenesis.com/v2/xlsx_answers/{ENGAGE_ORG_SLUG}",
params={
"activity_filter": ENGAGE_ACTIVITY_SLUG,
"date_filter": ["2022-01-01", "2023-01-31"],
},
headers={"Authorization": f"Bearer {access_token}"},
)
with open("report_file.xlsx", "wb") as f:
f.write(response.content)
python3 -m venv venv
source venv/bin/activate
pip install requests
python3 my_sample_script.py
import requests
AUTH_ENDPOINT = "https://auth.longenesis.com/realms/curator-engage/protocol/openid-connect/token"
USERNAME = "<your username>"
PASSWORD = "<your password>"
CLIENT_ID = "<Longenesis issued client id>"
CLIENT_SECRET = "<Longenesis issued client id>"
ENGAGE_ORG_SLUG = "<orgagization slug>"
ENGAGE_PROJECT_SLUG = "<project slug>"
ENGAGE_ACTIVITY_SLUG = "<activity slug>"
ENGAGE_SUBMISSION_ID = 12345600 # refer to the json with exported submissions
access_token = requests.post(
AUTH_ENDPOINT,
data={
"username": USERNAME,
"password": PASSWORD,
"grant_type": "password",
"client_id": CLIENT_ID,
"client_secret": CLIENT_SECRET,
},
).json()["access_token"]
response = requests.get(
f"/pdf/{ENGAGE_ORG_SLUG}/{ENGAGE_PROJECT_SLUG}/{ENGAGE_ACTIVITY_SLUG}/{ENGAGE_SUBMISSION_ID}/admin_download",
params={
"lang": "en", # or any other language that is supported by Engage
"include_sections": ["report", "pinned_questions", "calculated_answers", "response_alerts", "localized_answers"],
},
headers={"Authorization": f"Bearer {access_token}"},
)
with open("report_document.pdf", "wb") as f:
f.write(response.content)