"bank_transaction or bank_account required" when explaining expense bank account txn

Hey folks

I’m trying to explain a bank account txn by POSTing the following

{"bank_transaction_explanation":{"dated_on":"2019-06-02","category":"https://api.freeagent.com/v2/categories/285","bank_transaction":"https://api.freeagent.com/v2/bank_transactions/187996537","gross_value":"-13.0","description":"NENNO                  LONDON,GBR//DEBIT/","sales_tax_rate":"20"}}

to

https://api.freeagent.com/v2/bank_transaction_explanations

but I always get back a 400 response:

{"errors":{"error":{"message":"bank_transaction or bank_account required"}}}

Does anyone have a feeling for what I’m doing wrong here? From what I can see, no matter what I do (eg removing / adding other fields) I always see that same error. Does anyone know what the real problem is here?

Many thanks,
Rob

Hi Rob :wave:

Despite what the error message says, having looked at the specific example in the docs could you try passing in a bank_account parameter as well and see if that works?

Cheers,
Olly

Hi Olly

{"bank_transaction_explanation":{"dated_on":"2019-06-02","category":"https://api.freeagent.com/v2/categories/285","bank_transaction":"https://api.freeagent.com/v2/bank_transactions/187996537","bank_account":"https://api.freeagent.com/v2/bank_accounts/563048","gross_value":"-13.0","description":"NENNO                  LONDON,GBR//DEBIT/","sales_tax_rate":"20"}}'`

I tried with the bank_account too ^ - same error I’m afraid :slightly_frowning_face:

Thanks,
Rob

Hi Rob,

Sorry to hear you’re having trouble submitting a banking transaction explanation.

I’m Kyle a member of the banking team here at FreeAgent, and I’ll be more than happy to help you resolve this issue.

From the looks of things, the JSON payload you are submitting is ok. (even without bank_account)

As you are submitting JSON, please be sure to send the request with the header Content-Type application/json.

I have tested locally and I was able to replicate the 400 Bad Request error you where experiencing by omitting the Content-Type.

Here is a cURL request that should be successful, note the Content-Type header.

curl -X POST \
  https://api.freeagent.com/v2/bank_transaction_explanations \
  -H 'Content-Type: application/json' \
  -H 'Cookie:  fa_user_session_key=REDACTED; _fa_session_2=REDACTED' \
  -d '{
    "bank_transaction_explanation": {
        "sales_tax_rate": "20",
        "dated_on": "2019-06-02",
        "description": "NENNO                  LONDON,GBR//DEBIT/",
        "gross_value": "-13.0",
        "bank_transaction": "https://api.freeagent.com/v2/bank_transactions/187996537",
        "category": "https://api.freeagent.com/v2/categories/285"
    }
}'

I hope this helps you with your API query.

Kind Regards
Kyle

Ah - super helpful - thanks. I will try this later on :+1:

Edit: It worked thanks!

Hi Rob,

I am glad we where able to resolve your issue. I hope you have a great day with your project.

Kind regards
Kyle.

1 Like