Engine_size and engine_type errors for create Expense

When I call the expense API including all required fields plus the values for engine_size and engine_type, I get these errors
{“errors”:[{“message”:“engine_type is out of range”},{“message”:“engine_size is out of range”}]}

Even though I have supplied both values as per instructions.

Below is an example of what I am posting.
{
“expenses”: [
{“user”:“https://api.freeagent.com/v2/users/632360",“project”:“https://api.freeagent.com/v2/projects/1896041”,“category”:“https://api.freeagent.com/v2/categories/249”,“dated_on”:“2018-07-04”,“description”:"Chinnor to Whiteley”,“mileage”:“90”,“vehicle_type”:“Car”,“engine_type”:“Diesel”,“engine_size”:“Up to 1400cc” }
]
}
Please help.

Doug

Hi, Doug. The problem is two fold - 1) when creating an expense, the root key should be “expense”. 2) When creating an expense, you shouldn’t pass in an array. So your data should look like this:

{
“expense”:
{“user”:“https://api.freeagent.com/v2/users/632360",“project”:“https://api.freeagent.com/v2/projects/1896041”,“category”:“https://api.freeagent.com/v2/categories/249”,“dated_on”:“2018-07-04”,“description”:"Chinnor [api.freeagent.com] to Whiteley”,“mileage”:“90”,“vehicle_type”:“Car”,“engine_type”:“Diesel”,“engine_size”:“Up to 1400cc” }
}

If you’re thinking that’s an unhelpful error message, I agree, and I’ll make an internal card to look at it.

Pat George, FreeAgent

Thanks for that. Yes it worked when I changed it to “expense” without an array. However I was hoping to do a batch update, as per the docs.

Good call, Doug, you’re right. Let me look into it more.

Doug,

Just to keep you up-to-date, I’m pretty sure this is a bug. I’ve got a fix to run by the team and I hope to get it deploy this week. Sorry about this.

Doug,

This is a bug, I have a fix, it’ll go out first thing on Monday.

Again, I apologize for the problems it’s caused and the delay in getting it out. I hope you have a good weekend regardless.

Pat

1 Like

Doug,

I pushed the fix out this morning. Please let me know how you get along with it.

Yes thanks that works now! Cheers for the fast fix.