1

I'm using Netsuite's Postman collection (which takes care of the Oauth1 stuff), and am POSTing to this endpoint:

{{proto}}://{{host}}/rest/platform/{{version}}/record/salesorder

... and the body is something like this:

{
  "customForm": "999",
  "entity": {
    "id": "1111"
  },
  "department": {
    "id": "2222"
  },
  "subsidiary": {
    "id": "33"
  },
  "otherRefNum": "TEST-PO",
  "location": {
    "id": "444"
  },
  "item": {
    "items": [
        {
          "item": { "id": "555555" },
          "inventorylocation": {  "id": "444" },
          "price": { "id": "-1" },
          "grossAmt": 999,
          "quantity": 1
        }
    ]
  }
}

I'm trying to assign a location on the item level. The above request creates a sales order ok (without the line-level location assignment) if I remove the inventorylocation line, but with that in there, I get this error: Unknown reference or subrecord field inventorylocation in request body.

Netsuite's REST API documentation is here: https://system.netsuite.com/help/helpcenter/en_US/APIs/REST_API_Browser/record/v1/2019.2/index.html#tag-salesorder

I have also tried substituting location and moving the fields around a bit, without success. (either the salesorder is created without a line-level location assignment, or I get an error similar to the above error.

Any ideas?

Silas Palmer
  • 2,687
  • 1
  • 29
  • 30

2 Answers2

1

From the documentation you linked, it appears that the field id you need is inventorylocation rather than itemlocation.

salesorder-itemElement

...
giftCertRecipientName Recipient Name: string
id [Missing Label:id]: string
inventorydetail: salesorder-item-inventorydetail
inventorylocation: location
inventorysubsidiary: subsidiary
isClosed Closed: boolean
...

Krypton
  • 4,394
  • 2
  • 9
  • 13
  • Reference: https://system.netsuite.com/help/helpcenter/en_US/APIs/REST_API_Browser/record/v1/2019.2/index.html#/definitions/salesorder-itemCollection – erictgrubaugh Mar 26 '20 at 02:20
  • Good suggestion, but changing itemlocation to inventorylocation gives the same error. I've edited the question. – Silas Palmer Mar 30 '20 at 04:06
0

Based on the documentation for a salesOrder-itemElement, it looks like that key is correct.

Have you tried the "location": "{ID}" variation?

In LedgerSync it looks like the request for creating an invoice results in this body:

{
    "entity": "309",
    "location": "1",
    "sublist": {
        "items": [
            {
                "amount": 12345,
                "description": "Test Line Item FLURYAOLJLFADYGR-1"
            },
            {
                "amount": 12345,
                "description": "Test Line Item FLURYAOLUFUTBYJD-2"
            }
        ]
    }
}

There also is a salesOrder-item-inventorydetail object that also contains a location. Perhaps you could use that one like so:

{
  "customForm": "999",
  "entity": {
    "id": "1111"
  },
  "department": {
    "id": "2222"
  },
  "subsidiary": {
    "id": "33"
  },
  "otherRefNum": "TEST-PO",
  "location": {
    "id": "444"
  },
  "item": {
    "items": [
        {
          "item": { "id": "555555" },
          "inventorydetail": {
            "location": "444"
          },
          "price": { "id": "-1" },
          "grossAmt": 999,
          "quantity": 1
        }
    ]
  }
}
Ryan
  • 641
  • 5
  • 17