【问题标题】:Netsuite - REST API - Making query with Token Based Authentication (TBA) - (in Python)Netsuite - REST API - 使用基于令牌的身份验证 (TBA) 进行查询 - (在 Python 中)
【发布时间】:2021-11-29 14:52:38
【问题描述】:

这是使用 Netsuite 基于令牌的身份验证 (TBA) REST Web 服务成功调用的后续行动,

我想获得一些关于如何执行查询的指导。

我应该读这样的记录(请看截图)

  • 如何执行特定查询(按表获取记录列表和特定记录)?

https://gist.github.com/axilaris/4386c3537d04737d3775c156562b7545

这是一个自定义记录,其 ID 类似于 customrecord1589

【问题讨论】:

  • 这是您尝试访问的自定义记录吗?
  • 是的,它有一个自定义 ID,例如 customrecord1589

标签: rest web-services oauth netsuite


【解决方案1】:

要查询特定记录:您需要在 Netsuite 中创建/部署一个 RESTlet,类似于以下内容:

/**
 * @NApiVersion 2.1
 * @NScriptType Restlet
 */
define([
    "N/log",
    "N/search",
], function (log, search) {
    
    function post(context) {
        return JSON.stringify(getCustomRecords(context));
    }

    function getCustomRecords(context) {
        log.debug('POST Context', context);
        return search.lookupFields({
            //Change CUSTOM_RECORD to the type of custom record you are querying
            type: search.Type.CUSTOM_RECORD + '1589',
            id: context.id,
            columns: context.fields,
        });
    }

    return {
        post: post,
    };
});

在您的 Python 脚本中:确保将请求的 URL 更改为这个新 RESTlet 的部署 URL。此外,请确保在您的 POST 请求有效负载中传递您需要的任何参数(例如我的示例中的“id”或“字段”)。所以而不是:

payload = {
 "name":"value",
 "foo":"bar",
 "duck":"hunt",
}

通过

payload = {
 "id":"9999999",
 "fields": ["custrecord_field1", "custrecord_field2"],
}

其中 id 是您要查询的记录的 internalid,fields 数组是您要从中获取值的字段的 internalid。

如果成功,结果应该在你的 python 脚本中显示为 conn.text!

【讨论】:

猜你喜欢
  • 2021-12-06
  • 1970-01-01
  • 1970-01-01
  • 2016-07-16
  • 2017-11-27
  • 1970-01-01
  • 2013-08-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多