Expensify.org/hunger SNAP campaign status 


The number of families signing up for reimbursement has vastly outnumbered the limited funds available. Though we’re unable to provide a specific timeline on when your report will be reimbursed, we’re doing our best to drive donations and keep our fund moving forward. Rest assured, we’ll review every report that’s submitted per our instructions. 


Thanks for your patience! 

Cannot export report

slaislai 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 '[email protected]_template.ftl' as is shown in your API doc
  • I have tried using requests.post (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

EXPENSIFY_API_ENDPOINT = "https://integrations.expensify.com/Integration-Server/ExpensifyIntegration"

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>
</#if>
<#assign reportNumber = 1>
<#assign expenseNumber = 1>
<#list reports as report>
<#list report.transactionList as expense>
<#-- Report level -->
${report.submitter.fullName},<#t>
${report.reportID},<#t>
${report.created},<#t>

    <#-- Expense level -->
    ${expense.merchant} - ${expense.comment},<#t>
    ${expense.category},<#t>
    ${expense.tag.ntag-1},<#t>
    ${expense.tag.ntag-2},<#t>
    ${expense.currency},<#t>
    ${expense.amount}<#lt>

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

</#list>"""

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 = requests.post(EXPENSIFY_API_ENDPOINT, data=params)
return response

def main():
params = create_request()
resp = send_request(params=params)
print(resp.content)

main()

Answers

Sign In or Register to comment.