Category defaulting to Sundries (280) when creating an expense

When I create a new expense, all fields seem to work (so far) accept category. For instance, from the documentation if I wanted to create a new Web Hosting expense I would expect the request body to be something like this

{
  category: "https://api.sandbox.freeagent.com/v2/categories/268",
  user: "https://api.sandbox,freeagent.com/v2/users/1",
  dated_on: "2021-08-08",
  description: "Etc..."
}

This creates the new expense successfully, however the category is always https://api.sandbox.freeagent.com/v2/categories/280

Is this a bug or am I doing something wrong?

Hi Jof,

I’ve managed to locate your requests against the sandbox in our logs, and we see the category in the original request coming through as https://api.sandbox.freeagent.com/v2/categories/280.

Would you be able to double check the request body please? Perhaps category is simply listed twice and we’re using the second.

Kind regards,
Dominic

Thanks for the fast reply, Dominic. This is the request body

  {
    expense: {
      type: 'Payment',
      category: 'https://api.sandbox.freeagent.com/v2/categories/280',
      user: 'https://api.sandbox.freeagent.com/v2/users/9266',
      dated_on: '2021-08-08',
      description: 'Foo #Expensify_Expense_ID=55843834797490180',
      currency: 'GBP',
      gross_value: '-79.00',
      attachment: {
        data: 'JVBERi0xLj...'
        content_type: 'application/x-pdf',
        file_name: 'test-file.pdf'
      }
    }
  }
}

That’s it.

Sorry, that’s a bad example. That’s one I was messing with. One sec

Aha, I was hard-coding it in my backend :man_facepalming:

Whoops! Glad it’s sorted :slight_smile:

Dominic