Creating expense always returns 404 on sandbox

I’m trying to upload my mileage automatically. I’m making a call into the expense endpoint on https://api.sandbox.freeagent.com/v2/expenses as a POST.

Body

{
  "expense": {
    "user": "https://api.sandbox.freeagent.com/v2/users/1770",
    "description": "Ashchurch station",
    "dated_on": "2017-11-16",
    "category": "https://api.sandbox.freeagent.com/v2/categories/249",
    "mileage": 12.2,
    "vehicle_type": "Car",
    "engine_type": "Diesel",
    "engine_size": "Over 2000cc",
    "have_vat_receipt": false
  }
}

Returns

{
    "errors": {
        "error": {
            "message": "Resource not found"
        }
    }
}

However, when I GET:/expenses, this has been registered fine. Am I doing something wrong, or is this a bug in the sandbox?

Hi @riggerthegeek,

Thanks for your question! Examining the body of the request you are posting, I would expect the request to succeed. In fact, if I use a similar request (with the user changed) on a sandbox account of my own, I do receive a 200 status, with the newly created expense being returned.

Can you try again, and see if you get the same error? If so we may need to look into the logs to see what’s going on. The easiest way for that to happen is for you to send me your integration/application’s name. You’ll see this if you sign into https://dev.freeagent.com; there will be a listing of “My Apps”. You can send this direct to me on the forum by clicking on my avatar and then selecting “Message” from my profile screen.

Let me know if retrying it works for you, or if you need any other help.

Best regards,
James

Hi @James_Bell

Thanks for getting back. I’ve tried again and still a problem. Will DM the details as requested

S

Hi @James_Bell

Unless I’m being a complete spanner (which is, granted, quite likely), there is no message button on your profile screen.

Anyway, the name of my app is “Homelab”.

Can you see if you can DM me - it may well be due to my account being fairly new?

S

Thanks @riggerthegeek - I’ll investigate and DM you. If it turns out to be a more general problem, we can fill in the details here for others to learn from!

1 Like

It seems there’s an issue with my company because I’d never setup my company through the sandbox website. As explained by @james_bell…

So, we’ve found your sandbox requests in the logs, and have diagnosed the problem. It appears that the company you are trying to create expenses for hasn’t completed set up yet. When someone creates a new company, the first time they sign in they will be presented with a series of screens to collect key data for the company, such as accounting dates, VAT information for UK companies and so on. Without this, FreeAgent can’t make some decisions it needs with regards to how to set up accounting ledgers.

I solved the problem by going through to https://login.sandbox.freeagent.com, logging in with my sandbox user and completing the setup. This now solves the 404 issue when creating a new expense.

I’ve not seen anything in the docs about setting up company, so hopefully this will solve the issue for someone else until the docs are updated.

1 Like