Unable to update existing explanations with PUT

Hi,

I’m trying to update an existing Bank Transaction Explanations by doing the following:

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

The documentation says that the payload of the PUT should

… have a root bank_transaction_explanation element, containing elements listed under Attributes that should be updated.

From that I’d expect to be able to PUT the following, but despite receiving a 200 back, no update is made:

PUT https://api.freeagent.com/v2/bank_transaction_explanations/12345
{
  "bank_transaction_explanation":  
  {
    "description":  "My new description"
  }
}

As I said - I get a 200 back, containing a JSON representation of the existing explanation (with previous description) but no update is made.

I’ve also tried using a fully formed explanation object, but with the description altered, but get the same behaviour:

PUT https://api.freeagent.com/v2/bank_transaction_explanations/11111
{
  "bank_transaction_explanation": {
    "bank_account":  "https://api.freeagent.com/v2/bank_accounts/22222",
    "category":  "https://api.freeagent.com/v2/categories/285",
    "dated_on":  "2019-06-19",
    "description":  "My new description",
    "transaction_description":  "COFFEE SHOP,GBR//DEBIT/£4.65",
    "gross_value":  "-4.65",
    "foreign_currency_value":  "0.0",
    "transfer_value":  "4.65",
    "type":  "Payment",
    "is_money_in":  false,
    "is_money_out":  true,
    "is_money_paid_to_user":  false,
    "url":  "https://api.freeagent.com/v2/bank_transaction_explanations/11111",
    "bank_transaction":  "https://api.freeagent.com/v2/bank_transactions/33333",
    "detail":  "Accommodation and Meals. Inc £0.78 VAT ",
    "is_locked":  false,
    "marked_for_review":  false,
    "has_pending_operation":  false,
    "sales_tax_status":  "TAXABLE",
    "sales_tax_rate":  "20.0",
    "sales_tax_value":  "-0.78"
  }
}

Just for the sake of it, I did also try using a POST but received a 500 response (didn’t expect it to work but perhaps a 500 is not an ideal response?).

I’m sure I must be doing something wrong, I just can’t see what! Grateful for any help!

Hi Nic,

Thanks for your message and I’ll happily take a look at this for you.

So that I can locate your requests in our logs, and hopefully spot the problem, could I ask that you provide some additional information from the list below?

The name of your app (as registered in Dev Dashboard)
Timestamps of your requests (in UTC)
The IP(s) from which your requests are being sent
Which environment are you querying? (production or sandbox)?

Thanks,
Dave J

Hi David,

Sure thing - here you go:

Name of App: TestApp (not very imaginative!)
Timestamps: Sent a request using minimal payload at 21:47:58 UTC, and then another using the full explanation at 21:52:07 UTC.
IP: 217.146.124.181
Environment: Production

Thanks,
Nic

Hi Dave - did you have any luck finding my requests in your logs?

Hi Nic,

Thanks for your message and my sincere apologies for the delay in coming back to you, we’re super busy here at the moment.

I’ve successfully found the 2 PUT requests that you highlighted in your last message. There is an error message in our logs that perhaps hints at the problem you’re experiencing:

Strong parameters dry_require expectation failed - param is missing or the value is empty - bank_transaction_explanation

This error suggests that your PUT payload is missing the bank_transaction_explanation key, though in the example you posted at the start of this thread, your changeset was correctly wrapped in a bank_transaction_explanation wrapper.

Are you 100% sure the request you’re sending is wrapped in a bank_transaction_explanation object? Our logs are suggesting otherwise, so it’s definitely worth double checking.

Cheers,
Dave

Hi Nic,

I’ve just looked a little deeper and found that your PUT request doesn’t appear to be sending a payload at all.
We’re receiving an empty PUT request to /v2/bank_transaction_explanations/id, which explains why nothing’s being updated when you make your request.

Could you take a closer look at your integration and perhaps send a test PUT request to a service like endpoints to take a closer look at the request payload being sent by your integration. I reckon you’ll be able to spot the problem using this service.

Hope this helps!
Dave J

Hi Dave,

Thanks for the pointer, I’ve got things working now.

In case anyone else encounters this, it turned out that I was sending a payload, but I’d failed to set the Content-Type header to application/json - once I’d done that it all worked as expected.

Thanks,
Nic