500 error when trying to POST or PUT a transaction

I'm not sure what I am missing here, but I am getting a 500 error whenever I try to either POST a new transaction or PUT to update an existing one.

Here is what I tried:

POST https://api.youneedabudget.com/v1/budgets/{my budget}/transactions
{
    "account_id":"{my account}",
    "amount":50000,
    "date":"2018-01-30",
    "payee_id": "5f8cb447-b652-4995-beb3-398d7bbd4e6b",
    "category_id": null,
    "cleared": "Uncleared",
    "approved": true,
    "memo":null
}

Response:

{
  "error": {
    "id": "500",
    "name": "internal_server_error",
    "detail": "An unexpected error has occurred"
  }
}

And here is the PUT...

PUT https://api.youneedabudget.com/v1/budgets/{my budget}/transactions/{my transaction}

Minimal body (I also tried a more full body, same result):

{
    "amount":50000
}

Response:

{
  "error": {
    "id": "500",
    "name": "internal_server_error",
    "detail": "An unexpected error has occurred"
  }
}

Please feel free to contact me directly if you would like the exact IDs.

Thanks!

4replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Ian Neubert  - You need to wrap the POST body in a transactions array object like this:

    {
      transactions: [
        {
          "account_id":"{my account}",
          "amount":50000,
          "date":"2018-01-30",
          "payee_id": "5f8cb447-b652-4995-beb3-398d7bbd4e6b",
          "category_id": null,
          "cleared": "Uncleared",
          "approved": true,
          "memo":null
        }
      ]
    }

    curl example:

    curl -X POST "https://api.youneedabudget.com/papi/v1/budgets/[budget_id]/transactions/bulk"  -H "accept: application/json" -H "Authorization: Bearer [access_token]"  -H "Content-Type: application/json"  -d "{ \"transactions\": [ { \"account_id\": \"[account_id]\", \"date\": \"2018-01-30\", \"amount\": 10000, \"payee_id\": null, \"category_id\": null, \"cleared\": \"Cleared\", \"approved\": true, \"memo\": \"\" } ]}"

    Obviously, a 500 response is not helpful here so I will make a change to ensure a helpful message is returned in a scenario like this.

    Like 1
  • I see. Thank you. Does it expect the transaction key as an array even when PUTing a single transaction to update?

    Like
  • Ian Neubert I apologize, my response was about the bulk POST endpoint but you asked about PUT/POST for a single transaction.  The body still needs to be wrapped in an object but for both POST /budgets/{budget_id}/transactions and PUT /budgets/{budget_id}/transactions/{transaction_id} it needs to be wrapped in an object named "transaction" (singular).  Like this:

    {
      transaction: {
          "account_id":"{my account}",
          "amount":50000,
          "date":"2018-01-30",
          "payee_id": "5f8cb447-b652-4995-beb3-398d7bbd4e6b",
          "category_id": null,
          "cleared": "Uncleared",
          "approved": true,
          "memo":null
       }
    }

    My prior response is still accurate for the POST /budgets/{budget_id}/transactions/bulk endpoint.

    Again, I'll work to make the error response more helpful here.

    Like 1
  • Makes sense. Great, thank you!

    Like
Like Follow
  • Status Answered
  • 3 yrs agoLast active
  • 4Replies
  • 383Views
  • 2 Following