Are you receiving SNAP/EBT benefits? The Expensify.org/SNAP-VAX campaign is live and accepting new members. Learn more about receiving $50 for submitting a SNAP receipt and $50 for getting your COVID-19 vaccine here and join today!

Receiving No Results From API

apendergrass
apendergrass Expensify Customer Posts: 1

I am working to get the Expensify API up and running using Python. I am able to submit a request successfully for an export of Expensify reports, then pass the fileName provided from that call to the API again for the downloader, but I continue to receive an empty result set. No errors, but I end up with a response from the downloader that looks like this: {'reports' : None}.

The relevant code I am running looks like this:

template = """reports:
<#list reports as report>
 ... more template stuff...
 /#list>"""

params = {
            'requestJobDescription': json.dumps(
                {
                    "type":"file",
                    "credentials":
                        {
                        "partnerUserID":USER_ID,
                        "partnerUserSecret":SECRET
                        },
                    "inputSettings":
                        {
                            "type":"combinedReportData",
                            "reportState":"APPROVED,REIMBURSED",
                            "filters":
                                {
                                    "startDate":"2021-01-01"
                                }
                        },
                    "outputSettings":
                        {
                            "fileExtension":"csv",
                            "fileBasename":"myExport"
                        },
                    'onReceive':
                        {
                            "immediateResponse": ["returnRandomFileName"]
                        }

                }),
            "template": template

        }

response = requests.get(URL, params=params)
filename = response.content.decode('utf-8')

downloadParams = {

        'requestJobDescription': json.dumps(
            {
                "type":"download",
                "credentials":
                    {
                    "partnerUserID":USER_ID,
                    "partnerUserSecret":SECRET
                    },
                "fileName":filename
            })
    }

response = requests.get(URL, params=downloadParams)
download = response.content

reports = yaml.load(download, Loader=yaml.FullLoader)

#Prints {'reports': None}
print(reports)


Sign In or Register to comment.