首页 > 解决方案 > NetSuite REST API 调用是否存在已知的偏移限制?

问题描述

世界!我们正在尝试使用NetSuite SuiteQL REST API来拉取数据。它对于我们采购的大多数记录都非常有效,但是当我们遇到大表时,我们遇到了一个有趣的障碍。

由于单页数据的已知限制是 1,000 行,我们只是以 1,000 的限制来调用它,并将偏移量设置为 1,000 行增量。当我们为大于 100,000 行的记录获得 100,000 行的偏移量时,会发生一些有趣的事情。

如果我们调用https://myinstance.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=1000&offset=98000,我们会得到我们期望的所有链接。

{
"links": [
    {
        "rel": "previous",
        "href": "https://myinstance.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=1000&offset=97000"
    },
    {
        "rel": "first",
        "href": "https://myinstance.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=1000&offset=0"
    },
    {
        "rel": "next",
        "href": "https://myinstance.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=1000&offset=99000"
    },
    {
        "rel": "last",
        "href": "https://myinstance.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=1000&offset=753000"
    },
    {
        "rel": "self",
        "href": "https://myinstance.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=1000&offset=98000"
    }
],
"count": 1000,
"hasMore": true,
"items": [
    {
        [heres my data]...

将其设置为 99,000,很多信息就会消失。就好像它认为这是最后一页。

{
"links": [
    {
        "rel": "previous",
        "href": "https://myinstance.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=1000&offset=98000"
    },
    {
        "rel": "first",
        "href": "https://myinstance.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=1000&offset=0"
    },
    {
        "rel": "self",
        "href": "https://myinstance.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=1000&offset=99000"
    }
],
"count": 1000,
"hasMore": false,
"items": [
    {
        [heres my data]...

将其设置为 100,000 会给我一个错误。

{
"type": "https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5",
"title": "Not Found",
"status": 404,
"o:errorDetails": [
    {
        "detail": "The specified query parameter 'offset' is out of bounds. Provide value between 0 and 753000.",
        "o:errorQueryParam": "offset",
        "o:errorCode": "INVALID_PARAMETER"
    }
]

有没有人见过这种行为?我浏览了文档,找不到任何关于页面偏移限制的提及,所以我认为这可能是某种错误(事实上它甚至告诉你最大界限并且它明显高于指定的偏移量使得我认为这是一个错误),但希望有人可能以前见过这个,甚至更好的是,对如何解决这个问题有想法!

标签: restnetsuiteerp

解决方案


NetSuite REST Web 服务的官方文档提到了这个限制 [ 1 ]:

使用 SuiteQL 查询,您最多可以返回 100,000 个结果。有关详细信息,请参阅 query.runSuiteQLPaged(options)。


推荐阅读