Cannot export report

slai Expensify Customer Posts: 1

Hi there, I cannot seem to export a report using python3. I believe I have followed all the correct steps.

  • Note that and are fill ins.
  • I have tried calling the template as another .ftl file and storing the template as a string in the same script (below).
  • I am using the python requests module (is this possible?)
  • Do I need python to perform the curl on a command line?
  • I have used curl on the command line with the same template and it works fine
  • How do you insert the template call using python requests module
  • I have tried stringifying 'requestJobDescription={...}' --data-urlencode 'template@my_template.ftl' as is shown in your API doc
  • I have tried using (which is the only one that should work) and requests.get (just for kicks)
    ** I get HTTP 404 whenever I run with post
    ** I get HTTP 400 whenever I run with get (b/c you can't use get)

Below is my simplified code (.py files cannot be attached). Any help getting this to work would be great.

import logging
import json
import requests
from urllib.parse import urlencode


type = "file"

credentials = {
"partnerUserID": "",
"partnerUserSecret": ""

onReceive = {
"immediateResponse": ["returnRandomFileName"]

inputSettings = {
"type": "combinedReportData",
"filters": {
"reportIDList": "38179851"

outputSettings = {
"fileExtension": "csv"

template = """
<#if addHeader == true>
Employee,ID,Date,Merchant and Comment,Category,Department,Location,Currency,Amount<#lt>
<#assign reportNumber = 1>
<#assign expenseNumber = 1>
<#list reports as report>
<#list report.transactionList as expense>
<#-- Report level -->

    <#-- Expense level -->
    ${expense.merchant} - ${expense.comment},<#t>

    <#assign expenseNumber = expenseNumber + 1>
<#assign reportNumber = reportNumber + 1>


def create_request():
params = {
"requestJobDescription": json.dumps({
"type": type,
"credentials": credentials,
"onReceive": onReceive,
"inputSettings": inputSettings,
"outputSettings": outputSettings
"template": urlencode({"template": template})
# Have also tried -- "template": template

return params

def send_request(params):
response =, data=params)
return response

def main():
params = create_request()
resp = send_request(params=params)