UiPath Documentation
functions
latest
false
函数用户指南
  • 概述
    • 关于函数
  • JavaScript functions
    • 入门指南
    • Building JavaScript functions
    • HTTP triggers and routing
    • Function context
    • 访问平台服务
    • 测试和调试
  • Python 函数
  • 部署并运行
重要 :
请注意,此内容已使用机器翻译进行了本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。

测试和调试

Run JavaScript functions locally, call them over HTTP, execute one as a job, and validate the packaged project before publishing.

Functions run locally before they are packaged, against the same runtime and the same routing the platform uses.

Serve and call

uip function serve
uip function serve

Starts a hot-reload server on port 7070; --port changes it. Every HTTP function is callable at its declared path, and the root URL lists the registered routes.

Call a served function with curl at its declared path:

curl -X POST http://localhost:7070/hello \
  -H "Content-Type: application/json" \
  -d '{"name":"Alice"}'
curl -X POST http://localhost:7070/hello \
  -H "Content-Type: application/json" \
  -d '{"name":"Alice"}'

serve also takes --runtime to choose the runtime, node or deno.

Run one as a job

uip function run --function process-order --input '{"orderId":"A-1"}'
uip function run --function process-order --input '{"orderId":"A-1"}'

run executes the function once the way the platform runs a job, then prints a JobResult carrying the status and the output arguments. It does not need serve and makes no HTTP request, so ctx.params and ctx.headers are empty — the same conditions a deployed job function sees. Use it to test a function that declares no method and path.

Pass --entrypoint instead of --function to point at a file directly. One of the two is required.

Reaching Orchestrator locally

ctx.robot is null in a local run, and ctx.platform is built from environment variables. Put them in a .env file at the project root:

UIPATH_ACCESS_TOKEN=<your-access-token>
UIPATH_BASE_URL=https://cloud.uipath.com
UIPATH_ORG_ID=<org id>
UIPATH_TENANT_ID=<tenant id>
UIPATH_ACCESS_TOKEN=<your-access-token>
UIPATH_BASE_URL=https://cloud.uipath.com
UIPATH_ORG_ID=<org id>
UIPATH_TENANT_ID=<tenant id>

serve loads that file automatically on both supported runtimes. Exporting the variables in your shell works too.

Validating the packaged project

serve --production and run --production reproduce a platform cold start: no hot reload, and the installed server runner is reused rather than rebuilt. Running the packed output this way surfaces the failures the platform would hit on deployment — most often a runtime dependency that was left in devDependencies. See the CLI reference for the full recipe.

后续步骤

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新