3

While fetching the data from Netsuite using REST web Services. I am getting the following data as response. Is there any way where instead of HATEOAS links, I can get the actual data? I want to dump all the data to a file and in doing so I would have to make multiple calls with each id to get the data. Is there any way I can fetch all of the data with a single API call?

{
    "links": [
        {
            "rel": "next",
            "href": "https://demo123.suitetalk.api.netsuite.com/services/rest/record/v1/salesorder?limit=2&offset=2"
        },
        {
            "rel": "last",
            "href": "https://demo123.suitetalk.api.netsuite.com/services/rest/record/v1/salesorder?limit=2&offset=8"
        },
        {
            "rel": "self",
            "href": "https://demo123.suitetalk.api.netsuite.com/services/rest/record/v1/salesOrder/?limit=2"
        }
    ],
    "count": 2,
    "hasMore": true,
    "items": [
        {
            "links": [
                {
                    "rel": "self",
                    "href": "https://demo123.suitetalk.api.netsuite.com/services/rest/record/v1/salesorder/39"
                }
            ],
            "id": "39"
        },
        {
            "links": [
                {
                    "rel": "self",
                    "href": "https://demo123.suitetalk.api.netsuite.com/services/rest/record/v1/salesorder/40"
                }
            ],
            "id": "40"
        }
    ],
    "offset": 0,
    "totalResults": 8
}
ROBCROSS
  • 31
  • 3

1 Answers1

1

Use the expandSubResources parameter as part of your get request. Set it to true to expand subitems and sublists.


hat tip @johny for the assist!

2ps
  • 15,099
  • 2
  • 27
  • 47
  • The correct parameter is `expandSubResources=true` Official documentation: https://nlcorp.app.netsuite.com/app/help/helpcenter.nl?fid=section_1545141947.html – Johny Jan 26 '21 at 08:36
  • 1
    `expandSubResources=true` will work only while fetching a particular record. for e.g `https://demo123.suitetalk.api.netsuite.com/services/rest/record/v1/salesorder/39`, here I am fetching the record with internal id 39. While getting the list of items `expandSubResources` doesn't work, rather you get an error message saying `Invalid query parameter name 'expandSubResources'. Use one of the following valid query parameters: q, limit, offset.` – ROBCROSS Feb 02 '21 at 07:27
  • 1
    You can alternatively use the suite_ql / search endpoint to use a suite ql query to get the data that you need. e.g., `select item.id, item.displayname from item where itemtype='InvtPart'` – 2ps Feb 03 '21 at 16:22
  • @ROBCROSS Are you able to find solution for this? – Kamal Pandey Sep 15 '21 at 08:34