How can we help?

How to Upload Expense Files Using Postman

Tony Chong Flannery
Tony Chong Flannery
  • Updated

Overview

This article describes how to upload expenses using Postman

In Torii

Create an API Key

  1. Log in to Torii as an admin.

  2. Go to Settings > API Access, then click Generate API Key.

  3. Select Full Access (default), then click Generate key.

  4. Save the key in a password manager/secrets vault since Torii will not display it again.

Steps in Postman

Get File Upload Parameters from Torii’s API

  1. Select GET from the HTTP method dropdown and enter https://api.toriihq.com/beta/files/url as the URL. Specify a name (filename) and type (MIME type) under “Params.” This example uses an XLS file called “upload_text.xls” (see the Note below for the most common MIME types).

    Note: It’s critical to get the “type” parameter correct or later steps will fail. Here are some of the most common options. 
    .csv: text/csv
    .xls: application/vnd.ms-excel
    .xlsx: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

     

  2. In the “Authorization” tab, select Bearer Token and then paste your Torii API Key in the “Token” field.

  3. Click Send.

  4. The response body will return key-value pairs for “url” and “filePath.” Both will be used in subsequent steps.

Create a Compatible Expense File

  1. Log in to Torii as an admin.

  2. Go to Expenses > Expense Files, then click Upload expenses report.

  3. Click template in the popup that appears to download a template in XLSX format.

  4. From here, you can either copy and paste your expense data into the template or reformat an existing expense file to match the template's column headers and column order. This example will use an XLS file formatted according to the template.

Upload Your Expense File

  1. Open a new Postman tab, select PUT from the HTTP method dropdown, and enter the URL returned from the previous GET command.

  2. Click the “Body” tab, select binary, then click Select File to open a file browser, then find the file you created and double-click it to attach it.

  3. Click Send to upload your file.

Get Your File ID

  1. Open a new Postman tab, select POST from the HTTP method dropdown, and enter the URL https://api.toriihq.com/beta/files.

  2. Add your API Key to the “Authorization” tab as you did previously.

  3. In the “Body” tab, enter two key-value pairs in raw JSON format: path (the value returned as “filePath” above) and type (”expenseReport”). It should look like this:

  4. Click Send.

  5. The response will return an “id” value that you’ll need in the next step.

    mceclip0.png

Parse Your Expense File

  1. Open a new Postman tab, select PUT from the HTTP method dropdown, and enter the URL https://api.toriihq.com/beta/parsings/automatic.
  2. Add your API Key to the “Authorization” tab as you did previously.
  3. In the “Body” tab, enter the file ID you received in raw JSON format as the value for the key “idFile.” It should look like this:
    mceclip1.png
  4. Click Send to have Torii’s parsing service try to parse the file automatically.
  5. The response will return an “id” value that you’ll need in the (optional) next step.

Verify Successful File Parsing

  1. Open a new Postman tab, select GET from the HTTP method dropdown, and enter the URL https://api.toriihq.com/beta/parsings/[parse id from the previous step].
  2. Add your API Key to the “Authorization” tab as you did previously.
  3. Click Send.
  4. Review the output to verify successful file parsing.
  5. Your uploaded and the parsed file will also appear in Torii under Expenses > Expense files.

Manual Parsing

If for some reason the automatic parsing didn’t work, you can also parse columns manually by sending a PUT to https://api.toriihq.com/beta/parsings/manual

Here is an example of a raw JSON “Body” payload for manual parsing:

{
"parseConfig": {
"idFile": "{FILE_ID}",
"transactionDateColumn": "A",
"descriptionColumn": "B",
"amountColumn": "C",
"dateFormat": "DD/MM/YYYY",
"currencyColumn": "D"
}
}

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request