微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

NetSuite REST API 调用是否有已知的偏移限制?

如何解决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"
    },"href": "https://myinstance.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=1000&offset=99000"
    }
],"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"
    }
]

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

解决方法

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

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。