在沙箱中执行代码 | 大装置帮助中心
跳到主要内容

在沙箱中执行代码

POST https://sandbox.cn-sh-01.sensecoreapi.cn/studio/sandbox/v1/workspaces/{workspace_id}/sandboxes/{sandbox_id}:execute

请求头(Request Header)

请求参数(Request Parameters)

名称类型必须位置描述
workspace_idstringpath工作空间 ID
sandbox_idstringpath沙箱 ID
codestringbody待执行代码
languagestringbody编程语言,当前仅支持python
environmentobjectbody环境变量(键值对)
execution_timeoutintegerbody超时时间,单位为秒,可设置范围为,默认值为60秒
stdinstringbody标准输入

响应(Response)

异常情况请参考异常响应说明

字段类型描述
execution_idstring执行 ID
resultobject执行结果

其中,result的参数如下:

字段类型描述
exit_codeint32退出码
stdoutstring标准输出
stderrstring标准错误
execution_timeint64执行耗时(毫秒)

响应示例(Response Example)

  • 正常响应

{
"execution_id": "string",
"result": {
"exit_code": 0,
"stdout": "string",
"stderr": "string",
"execution_time": 0
}
}