简体   繁体   English

可以使用 Netsuites SuiteScript 框架根据对脚本 url 的 GET 请求返回信息吗

[英]Can Netsuites SuiteScript framework be used to return information based on a GET request to the scripts url

I am wanting to get information from Netsuite and save it to my web app.我想从 Netsuite 获取信息并将其保存到我的 Web 应用程序中。 I have classes that send information to Netsuite that then gets processed by a suite script but I am not sure how to get Suitescripts to return information.我有一些类将信息发送到 Netsuite,然后由套件脚本处理,但我不确定如何让 Suitescripts 返回信息。 When I look at the Suitescript documentation there doesn't seem to be any examples or mentions of returning data.当我查看 Suitescript 文档时,似乎没有任何示例或提及返回数据。

You could set up and use SuiteTalk which is a native API NetSuite that NetSuite offers in SOAP and REST to fetch data from NetSuite.您可以设置并使用SuiteTalk ,它是 NetSuite 在 SOAP 和REST 中提供的原生 API NetSuite,用于从 NetSuite 获取数据。 I personally have never used SuiteTalk and prefer creating my own RESTlets that fetch or post data.我个人从未使用过 SuiteTalk,更喜欢创建自己的 RESTlets 来获取或发布数据。 Here's a nice video that explains how to create a RESTlet.这是一个很好的视频,解释了如何创建 RESTlet。

You use a SuiteScript of type RESTlet to create custom API endpoints.您可以使用 RESTlet 类型的SuiteScript创建自定义 API 端点。 You can find bunch of examples in that link to use for your API.您可以在该链接中找到大量用于 API 的示例。

As you mentioned, a SuiteScript handles your GET request.正如您提到的,SuiteScript 处理您的 GET 请求。 That SuiteScript is a RESTLet. SuiteScript 是一个 RESTLet。 You need to modify the same function inside the RESTLet that handles the GET request, to return any data to your external web app.您需要修改处理 GET 请求的 RESTLet 内的相同函数,以将任何数据返回到您的外部 Web 应用程序。 Don't forget to convert your data to a string, using JSON.stringify() , before returning it.在返回数据之前,不要忘记使用JSON.stringify()将数据转换为字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM