First time SoftLedger API users may see this error if a request to create an object in SoftLedger which references an alternate object is sent to the api. The _id is used in the API since this field is auto generated by the system and required to be unique, whereas the user inputted id fields are not required to be unique.


This usually indicates that the incorrect field from the referenced table is being used.


The example above occurred when trying to create a Journal entry using a LedgerAccount's number field instead of it's _id field.


In order to properly perform this request you can follow these steps.


1. Request (and possibly store/cache) the SoftLedger LedgerAccount details for the accounts you want to post

//nodejs with axios example to request ledger account details

const res = await axios({
  method: 'GET',
  url: 'https://api.softledger.com/api/ledger_accounts',
  headers: {
    // Authorization: <your token>
    'Content-Type': 'application/json'
  },
  params: {
    limit: 1,
    where: {
      number: 630103
    }
  }
})
/*
res.data = {
  totalItems: 1,
  data: [{
    _id: 782134,
    number: "630103",
    // ...rest of data
  }]
}
*/


2. Create a Journal entry using the Ledger Account's _id value

//nodejs with axios example to create a journal entry

const res = await axios({
  method: 'POST',
  url: 'https://api.softledger.com/api/journals',
  headers: {
    // Authorization: <your token>
    'Content-Type': 'application/json'
  },
  data: {
    "status": "draft",
    "entryType": "Standard",
    "sourceLedger": "Financial",
    "reference": "Test Data",
    "currency": "USD",
    "Transactions": [
      {
      "description": "test transaction",
      "debit": "0",
      "credit": "100.24",
      "transactionDate": "2019-08-24",
      "postedDate": "2019-08-24",
      "LedgerAccountId": 782134, //_id value returned from above query
      "LocationId": 892, //Location._id value received from GET api/locations
      },
      // ...additional transactions
    ]
  }
})