We're using REST Web Services to create (POST) and...
# integrations
s
We're using REST Web Services to create (POST) and update (PATCH) journal entries in NetSuite. The POST request works perfectly, creating the journal entry without issues. However, we are running into a problem with the PATCH request. The third-party system is sending the complete set of journal entry line items, where some existing lines may be updated, and new lines may be added. We’ve tried using the
replace = 'sublist'
option (for the JE lines), as well as other methods, but I keep receiving the following error:
Copy code
{
  "type": "<https://www.rfc-editor.org/rfc/rfc9110.html#section-15.5.1>",
  "title": "Bad Request",
  "status": 400,
  "o:errorDetails": [
    {
      "detail": "Error while accessing a resource. The record has been deleted since you retrieved it.",
      "o:errorCode": "USER_ERROR"
    }
  ]
}
It seems like the error is indicating that the record has been deleted since it was retrieved, but the record still exists in the system and no deletion has taken place. Has anyone encountered this issue before, or have any suggestions for resolving it?
b
what do the requests look like
s
Copy code
{
  "line": {
    "items": [
      {
        "custcol_ps_order_type_jv": "XXX",
        "custcol_ps_trade_type_jv": "XXX",
        "currency": "INR",
        "account": "1585",
        "custcol_ps_exchange_fullfilment_jv": "XXX",
        "department": "149",
        "class": "2",
        "debit": 6591292.32,
        "line": 0
      },
      {
        "custcol_ps_order_type_jv": "XXX",
        "custcol_ps_trade_type_jv": "XXX",
        "currency": "INR",
        "account": "1585",
        "custcol_ps_exchange_fullfilment_jv": "XXX",
        "department": "149",
        "class": "2",
        "credit": 6591292.32,
        "line": 1
      },
      {
        "custcol_ps_order_type_jv": "XXX",
        "custcol_ps_trade_type_jv": "XXX",
        "currency": "INR",
        "account": "1585",
        "custcol_ps_exchange_fullfilment_jv": "XXX",
        "department": "149",
        "class": "2",
        "debit": 2278,
        "line": 2
      },
      {
        "custcol_ps_order_type_jv": "XXX",
        "custcol_ps_trade_type_jv": "XXX",
        "currency": "INR",
        "account": "1585",
        "custcol_ps_exchange_fullfilment_jv": "XXX",
        "department": "149",
        "class": "2",
        "credit": 2278,
        "line": 3
      }
    ]
  }
}
PATCH request to https://XXXXXXX-sb1.suitetalk.api.netsuite.com/services/rest/record/v1/journalentry/356440 The above is the request payload and the URL being used. Certain values have been replaced with 'XXX' where necessary.
b
if this is a new account, you want to make you can make the matching edit in the ui
that class of error you are getting is very common on netsuite accounts that are not setup correctly
otherwise the only thing that looks suspect is the account field, which probably shouldnt all be the same value
s
@Sitaram upadhya Any way that you can only send the updated line items in the request instead of sending new ones in the same call with "line." I believe that "line" is being mapped internally by NetSuite here for create cases, and when you're explicitly trying to set the value using "line," it may conflict with NetSuite's internal indexing imo. By sending only the modified lines with their existing "line" values, you avoid introducing new line items in the same request.