Issue with creating journals on production - Urgent **

Hi FreeAgent,

We’re having issues creating a journal on your production environment (“https://api.freeagent.com”). The creating journals is the only part that fails, grabbing the oAuth token and accounting categories work fine. When I go to post a journal, I get the following error
{
“errors”: {
“error”: {
“message”: “Required parameter missing: journal_set”
}
}
}

My JSON below includes the journal_set, so I could do some help on working out why this error is coming back

{
“journal_set”: {
“dated_on”: “2021-05-26”,
“description”: “Payroll M2 Monthly”,
“journal_entries”: [
{
“category”: “https://api.freeagent.com/v2/categories/249”,
“description”: “Wages and Salary for pay period ending 30/06/2020”,
“debit_value”: “6634.94”
},
{
“category”: “https://api.freeagent.com/v2/categories/249”,
“description”: “Wages Expense for pay period ending 30/06/2020”,
“debit_value”: “-9416.67”
},
{
“category”: “https://api.freeagent.com/v2/categories/249”,
“description”: “Student Loan Liability for pay period ending 30/06/2020”,
“debit_value”: “285.00”
},
{
“category”: “https://api.freeagent.com/v2/categories/249”,
“description”: “Post Graduate Loan Liability for pay period ending 30/06/2020”,
“debit_value”: “85.00”
},
{
“category”: “https://api.freeagent.com/v2/categories/249”,
“description”: “PAYE Liability for pay period ending 30/06/2020”,
“debit_value”: “1175.80”
},
{
“category”: “https://api.freeagent.com/v2/categories/249”,
“description”: “Employer Pension Expense for pay period ending 30/06/2020”,
“debit_value”: “-235.72”
},
{
“category”: “https://api.freeagent.com/v2/categories/249”,
“description”: “Employer Pension Liability for pay period ending 30/06/2020”,
“debit_value”: “235.72”
},
{
“category”: “https://api.freeagent.com/v2/categories/249”,
“description”: “Employee Pension Liability for pay period ending 30/06/2020”,
“debit_value”: “392.85”
},
{
“category”: “https://api.freeagent.com/v2/categories/249”,
“description”: “National Insurance Expense for pay period ending 30/06/2020”,
“debit_value”: “-994.37”
},
{
“category”: “https://api.freeagent.com/v2/categories/249”,
“description”: “National Insurance Liability for pay period ending 30/06/2020”,
“debit_value”: “994.37”
},
{
“category”: “https://api.freeagent.com/v2/categories/249”,
“description”: “Employee National Insurance Liability for pay period ending 30/06/2020”,
“debit_value”: “843.08”
}
]
}
}

We have run a test using the sandbox and the journals export fine, it uses the same code. The only difference is the URL is changed from the sandbox (“https://api.sandbox.freeagent.com”) to prod (“https://api.freeagent.com”).

Our application on https://dev.freeagent.com/ is called ‘KeyPay - Singular business’. This is going to be affecting production customers, so thanks in advance for any quick responses

This is a common class of error if the Content-Type header is missing or wrong, as the JSON body of the request won’t be parsed by the server.

Check that your POST requests specify both of these headers:

Accept: application/json
Content-Type: application/json

Cheers,
Dominic

Hi Dominic,

I’ve tried that and it hasn’t worked.

The request

The response

This shows the breakdown of the request and the response. Any ideas ?

That’s better - it’s now failing because of the request content.

It looks like those accounting categories need the user (employee) specified, i.e. for salaries and pensions. The category 249 in your original post doesn’t have sub-categories, so works without specifying the user.

You can add the user to each journal entry:

"journal_entries": [
  {
    "category": "https://api.freeagent.com/v2/categories/901",
    "user": "https://api.freeagent.com/v2/users/123456789",
    "description": "Wages and Salary for pay period ending 30/06/2020",
    "debit_value": "6634.94"
  }
]

From the API you can find the user’s URL by calling GET /v2/users (docs). There are a few other types of category that may need other details to retrieve the right account, e.g. stock, bank accounts (docs).

Kind regards,
Dominic

Cheers Dominic, so that worked by adding the user to all journal rows. A question though, why do we have to attached the user to individual journal entries. Surely FreeAgent knows the user cause they created the oAuth connection ?

Glad that’s working!

A question though, why do we have to attached the user to individual journal entries. Surely FreeAgent knows the user cause they created the oAuth connection ?

The journals might not be for the same user as who originally authorised the API integration.

A FreeAgent account can have multiple users for all of the company’s directors, employees and accountants, so any journal entries about salaries etc need to be assigned to the correct user’s account rather than assuming it’s for the API authoriser.

Dominic

Hi Dominic,

For singular businesses I just hit the user/me endpoint to get the user ID however this doesn’t work for accountants. I get the following error: “You are not allowed to access this action.”

What’s my opinions here for getting the user ID when the user is an accountancy practice (FreeAgent Developer Dashboard)

Maybe the account manager ID instead ? Could you confirm what’s required here ?

For singular businesses I just hit the user/me endpoint to get the user ID

That’d only be applicable for a company with a single user, such as a sole trader.

If there are multiple employees, then you’ll need to find the appropriate user from GET /v2/users and supply that ID. Otherwise all of the salary journal entries will be attributed to one employee, as there are separate accounts per user. You can see each individual account under Accounting, Reports, Show Transactions and also Trial Balance, if they have entries.

The company should have a user for each employee (How to add a user), even if they have no access to FreeAgent.

What’s my opinions here for getting the user ID when the user is an accountancy practice? Maybe the account manager instead ? Could you confirm what’s required here ?

Same issue here really - it’d need to be one of the users in the account - an account manager ID wouldn’t work as they’re not part of the company.

Kind regards,
Dominic

We are having trouble when we are exporting the journal when the journal line for net payment (which should be an asset) is set to account category 750 - Bank Account. We have tried setting this to other current assets such as 620 - Prepayments and that goes through. It seems to just error with this one account. Is there a reason this would be happening?

Additionally we have some accounts that have been imported that we can’t see on the account categories in FreeAgent. Could you please tell us where these would be coming from?

image (19)

Hello, Gerard from FreeAgent here.

We are having trouble when we are exporting the journal when the journal line for net payment (which should be an asset) is set to account category 750 - Bank Account. We have tried setting this to other current assets such as 620 - Prepayments and that goes through. It seems to just error with this one account. Is there a reason this would be happening?

Yes, it’s mentioned briefly on the documentation for adding journal sets, but we don’t allow journalling to specific bank accounts using journal sets. The idea is that a bank account should only ever be balanced using the transactions inside that bank account (with the one exception of the opening balance for that bank account).

Additionally we have some accounts that have been imported that we can’t see on the account categories in FreeAgent. Could you please tell us where these would be coming from?

I’m afraid I’m not sure which accounts you mean specifically. From the image posted, I can see that these match up with the accounts we would add by default for a UK limited company on FreeAgent. Does that sound correct in this case?

Many thanks,
Gerard