500 (Internal Server Error) when creating multiple transactions

Hi there,

I'm trying to create transactions via the API, but I receive a 500 error (Internal Server Error).  From some experimentation, I receive an error when the request contains multiple transactions; it works successfully when the request contains only 1 transaction.

[Note that in the examples below, I have replaced my actual account ID with a different UUID and withheld the budget ID and auth token.]

Here is the failing case:

$ cat multiple.json
{
    "transactions": [
        {
            "account_id": "23381aa2-22c3-4669-ac64-2e34a98eece7",
            "amount": 100,
            "approved": false,
            "category_id": null,
            "cleared": "cleared",
            "date": "2019-12-05",
            "flag_color": null,
            "import_id": null,
            "memo": null,
            "payee_id": null,
            "payee_name": "Market Change"
        },
        {
            "account_id": "23381aa2-22c3-4669-ac64-2e34a98eece7",
            "amount": 200,
            "approved": false,
            "category_id": null,
            "cleared": "cleared",
            "date": "2019-12-06",
            "flag_color": null,
            "import_id": null,
            "memo": null,
            "payee_id": null,
            "payee_name": "Market Change"
        }
    ]
}
$ curl -X POST   -H "accept: application/json"   -H "Authorization: Bearer ${AUTH_TOKEN}"   -H "Content-Type: application/json"   -d "$(cat multiple.json)"   https://api.youneedabudget.com/v1/budgets/${BUDGET_ID}/transactions
{"error":{"id":"500","name":"internal_server_error","detail":"An unexpected error has occurred"}}

Here is the successful case:

$ cat single.json
{
    "transactions": [
        {
            "account_id": "23381aa2-22c3-4669-ac64-2e34a98eece7",
            "amount": 200,
            "approved": false,
            "category_id": null,
            "cleared": "cleared",
            "date": "2019-12-06",
            "flag_color": null,
            "import_id": null,
            "memo": null,
            "payee_id": null,
            "payee_name": "Market Change"
        }
    ]
}
$ curl -X POST   -H "accept: application/json"   -H "Authorization: Bearer ${AUTH_TOKEN}"   -H "Content-Type: application/json"   -d "$(cat single.json)"   https://api.youneedabudget.com/v1/budgets/${BUDGET_ID}/transactions
{"data":{"transaction_ids":["aed86dd8-11b5-41b5-9807-ed74894c4772"],"duplicate_import_ids":[],"transactions":[{"id":"aed86dd8-11b5-41b5-9807-ed74894c4772","date":"2019-12-06","amount":200,"memo":null,"cleared":"cleared","approved":false,"flag_color":null,"account_id":"23381aa2-22c3-4669-ac64-2e34a98eece7","account_name":"Savings","payee_id":"16e22eec-101a-4e6a-9815-1dc285a9d89f","payee_name":"Market Change","category_id":null,"category_name":null,"transfer_account_id":null,"transfer_transaction_id":null,"matched_transaction_id":null,"import_id":null,"deleted":false,"subtransactions":[]}],"server_knowledge":15396}}

This worked when I last ran my code in early December, but started returning an error when I ran it at the end of December.

Any ideas?  I'm quite likely missing something obvious here.

Thanks!

7replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Hi Cyan Trumpet ,

    In looking at the two examples you sent, I noticed the successful import only had one transaction, but the failed one had two transactions, like you mentioned. My thought there is that you have an import_id of "null", which means there's no separate identification between these transactions you're attempting to import. I wonder if you tried specifying either the transaction id or import_id if you would have success? 

    Give that a try and let me know if that helps!

    Like
  • Thank you for the prompt reply!

    I ran the two tests you suggested, and received the same error (500 - Internal Server Error) each time.

    Here is the first test, with just specifying an import_id:

    $ cat multiple.json
    {
        "transactions": [
            {
                "account_id": "23381aa2-22c3-4669-ac64-2e34a98eece7",
                "amount": 100,
                "approved": false,
                "category_id": null,
                "cleared": "cleared",
                "date": "2019-12-05",
                "flag_color": null,
                "import_id": "2020-01-06:test1",
                "memo": null,
                "payee_id": null,
                "payee_name": "Market Change"
            },
            {
                "account_id": "23381aa2-22c3-4669-ac64-2e34a98eece7",
                "amount": 200,
                "approved": false,
                "category_id": null,
                "cleared": "cleared",
                "date": "2019-12-06",
                "flag_color": null,
                "import_id": "2020-01-06:test2",
                "memo": null,
                "payee_id": null,
                "payee_name": "Market Change"
            }
        ]
    }

    Here is the second test, which also specifies an ID for each transaction: 

    $ cat multiple.json
    {
        "transactions": [
            {
                "id": "676a4768-d048-41ed-9394-757117d64d2b",
                "account_id": "23381aa2-22c3-4669-ac64-2e34a98eece7",
                "amount": 100,
                "approved": false,
                "category_id": null,
                "cleared": "cleared",
                "date": "2019-12-05",
                "flag_color": null,
                "import_id": "2020-01-06:test1",
                "memo": null,
                "payee_id": null,
                "payee_name": "Market Change"
            },
            {
                "id": "f3d1981a-311b-43da-8a67-f7d800309428",
                "account_id": "23381aa2-22c3-4669-ac64-2e34a98eece7",
                "amount": 200,
                "approved": false,
                "category_id": null,
                "cleared": "cleared",
                "date": "2019-12-06",
                "flag_color": null,
                "import_id": "2020-01-06:test2",
                "memo": null,
                "payee_id": null,
                "payee_name": "Market Change"
            }
        ]
    }

    As another random guess, I also tried with just omitting the null fields:

    $ cat multiple.json
    {
        "transactions": [
            {
                "account_id": "23381aa2-22c3-4669-ac64-2e34a98eece7",
                "amount": 100,
                "approved": false,
                "cleared": "cleared",
                "date": "2019-12-05",
                "import_id": "2020-01-06:test1",
                "payee_name": "Market Change"
            },
            {
                "account_id": "23381aa2-22c3-4669-ac64-2e34a98eece7",
                "amount": 200,
                "approved": false,
                "cleared": "cleared",
                "date": "2019-12-06",
                "import_id": "2020-01-06:test2",
                "payee_name": "Market Change"
            }
        ]
    }

    In each of these cases, running the same curl command as in the initial post, I receive the same error.

    Like
  • Hi  Cyan Trumpet

    I thought of one more thing! Is the budget that you're testing this on really large? We do have a limit on large budgets being able to create multiple transactions through the API at once. If that's what you're running into, you may want to try on a Fresh Start or new budget and confirm.

    Thanks!

    Like
  • Thanks for the reply!

    I guess it depends on what is considered "large" and on what dimension?  I have my financial history in there, so there are  many transactions. I don't think there a large number of budget categories though. 

    I can try to confirm on a new budget to confirm this is the reason and get back to here.

    As a permanent solution, I do not wish to do a Fresh Start, since that would compromise the long-term picture and reporting.  What are some of the other options?  One that comes to mind is to limit my program to create transactions one at a time, but then be subjected to the hourly rate limits; this would be rather unfortunate though.

    Like
  • Hi there,

    I created a new budget, and then retried the request in multiple.json from the original post, and it worked.

    Unfortuately, I don't really consider that a permanent solution.  Aside from hacking around this by creating one transaction at a time, are there any other ideas?

    Thanks!

    Like
  • Hi Cyan Trumpet ,

    For the API, there's a limit of the total number of transactions that can be in a budget and for the API to continue to work import multiple transactions. If a new budget worked, I'd recommend a Fresh Start, since your old budget must be past the upper limit of that multiple transaction creation.

     

    Thanks!

    Like
  • Gotcha. See above for why I don't wish to do that. 

    I guess I'm stuck with just needing to do them one at a time and then being capped at 200 per hour.

    Like
Like Follow
  • 1 mth agoLast active
  • 7Replies
  • 170Views
  • 2 Following