Hi All, I've been trying to get my head around an ...
# general
g
Hi All, I've been trying to get my head around an issue with the netsuite REST api for a few days now, i'm trying to create a return authorization that links to a sales order, it creates fine via the UI, i can create one no problem but it simply will not link back to the sales order. My payload is:
Copy code
{
  "entity": {
    "id": "116"
  },
  "trandate": "02/17/2025",
  "memo": "Shopify Refund for Order #2395",
  "item": {
    "items": [
      {
        "item": {
          "id": "14607",
          "rate": 1
        },
        "quantity": 1
      }
    ]
  }
}
but this always returns the 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. Please choose an item to add.",
      "o:errorPath": "item.items[0]",
      "o:errorCode": "USER_ERROR"
    }
  ]
}
I am attempting to do a POST to
<https://6370999-sb1.suitetalk.api.netsuite.com/services/rest/record/v1/salesorder/11885144/!transform/returnAuthorization>
Can anyone shed any light on this? Googl'ing doesn't really seem to give any insight, i've tried adding a line number but it returns the same error.
s
At a quick glance, it looks like your item structure is incorrect - the "rate" key should be moved outside of the object it's in and put at the same level as "quantity". i.e.:
Copy code
{
  "item": {
    "id": "14607"
  },
  "rate": 1,
  "quantity": 1
}
g
hey yeah i did spot that and fix it a few times, having gone over the docs several times this is the payload i've got now.
Copy code
{
  "entity": {
    "id": "116"
  },
  "item": {
    "items": [
      {
        "item": {
          "id": "14607"
        },
        "orderDoc": {
          "id": "11885144",
          "refName": "salesOrder"
        },
        "orderLine": 0,
        "quantity": 1
      }
    ]
  },
  "trandate": "02/17/2025"
}
And even this, just responds with
Response Body: {"type":"https://www.rfc-editor.org/rfc/rfc9110.html#section-15.6.1","title":"Internal Server Error","status":500,"o:errorDetails":[{"detail":"An unexpected error occurred. Error ID: m7ahawk71o6lld5cofafe","o:errorCode":"UNEXPECTED_ERROR"}]}
I've added ?replace=item to the URL after !transform/returnAuthorization to no avail too. What i do find odd, is that the
orderLine
key, if i remove it, i get the same error as before, but with it, i get this 500 error, which albeit isn't progress it IS a different error.
but im a little lost and just can't figure out why it isn't working from what i see in the API Docs.
j
is it auto adding all items from the SO when you do the transform? And thus erroring when you try to add the line?
g
So i figured out if i create the transform, then do an update (PATCH) of the RA thats created it seems to work out, which seems to be a valid way around it albeit adding an extra API call for the moment.
1