You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

通过REST API执行OML4Py嵌入脚本时为何收到JSON格式错误?

OML4Py REST API执行嵌入脚本时JSON格式错误修复

问题场景

通过REST API执行OML4Py嵌入脚本时触发JSON格式错误,执行的curl命令如下:

$ curl -i -X POST --header "Authorization: Bearer ${token}" 
--header 'Content-Type: application/json' --header 'Accept: application/json' 
-d '{"graphicsFlag":true, "service":"MEDIUM"}' 
"/oml/api/py-scripts/v1/do-eval/myscript"

返回的错误信息:

{"errorMessage":"Output malformed JSON. This could be caused by explicitly calling print() in the executed Python script. Remove print() call from the script should solve the issue.","errorCode":1026}

解决方法

根据错误提示,问题根源是执行的Python脚本中存在显式调用print()函数的情况,这些print输出会干扰API返回的JSON结构,导致格式异常。直接移除脚本中所有的print()调用即可解决该问题。

内容的提问来源于stack exchange,提问作者Philip Cannata

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 09:42:01